0

I am trying to read a txt file into R using this:
data<- read.csv("LifetimePrevalence_v2_2021_1021.txt")

I get this: Warning messages:

  1. In read.table(file = file, header = header, sep = sep, quote = quote, : line 1 appears to contain embedded nulls
  2. .... (there are several lines of similar warnings)

Here are the first few lines of the txt file, with first row header.

CMNCTN_ID,DT_RCVD,FK_RPTRPT_NBR,COMM_SRC_TYP_CD,CMNCTN_TYP_CD,DISP_TYP_CD,ChildID,ChildRoleType,ChildCounty,ChildZip,ChildBirthDate,ChildAge,ChildRace,AMER_IND_OR_ALSKA,BLCK_OR_AFR_AMER,ASIAN,NATIVE_HAWAIIAN,HISP_ORIG_IND,WHITE,FK_PERSID,PERS_CASE_ROLE_TYP,CNTY,ZIP,BRTH_DT,RACE,Age
1227541,2008-03-05,488526,SCHL,A   ,NONE,1983000,CHLD,MARICOPA            ,82341,1999-02-14,12,White,N,N,N,N,N,Y,1683107,MOTH,MARICOPA            ,85233,1976-09-13,White,31
1266416,2008-07-16,503737,MENT,A   ,NONE,1917897,CHLD,PIMA                ,85609,1999-02-14,12,White,N,N,N,N,N,Y,301736,MOTH,PIMA                ,85719,1970-04-11,White,38
182,1999-01-22,89495,NABR,A   ,NONE,220801,CHLD,,,,,Unknown,,,,,,,321795,MOTH,,,,Unknown,
1268677,1999-09-20,114918,RLTV,A   ,NONE,654610,CHLD,YAVAPAI             ,86329,1999-02-23,16,White,N,N,N,N,N,Y,434606,MOTH,YAVAPAI             ,86326,1959-08-18,White,40

I tried variations, like read.delim, but get the same warrning messages. The file that reads into the Global Environment has the correct number of objects, but 1 variable with all values NA.

IRTFM
  • 251,731
  • 20
  • 347
  • 472
  • Does this answer your question? [Get "embedded nul(s) found in input" when reading a csv using read.csv()](https://stackoverflow.com/questions/23209464/get-embedded-nuls-found-in-input-when-reading-a-csv-using-read-csv) – hyena Dec 31 '21 at 21:48

0 Answers0