|
Post by Carl Gundel on Aug 24, 2019 11:34:28 GMT -5
Liberty BASIC Essentials #4 - Reading CSV files into your programs A new video. Enjoy! youtu.be/VDpK3Nh4Sik
|
|
|
Post by pandawdy on Aug 24, 2019 13:53:25 GMT -5
that link on your desktop.. run basic 2.0. is that the newest version?
|
|
|
Post by pandawdy on Aug 24, 2019 14:35:28 GMT -5
that link on your desktop.. run basic 2.0. is that the newest version? Nevermind. I got excited because I thought it was run basic.. it's Just Basic 2.0
|
|
|
Post by cryptomen on Jan 2, 2024 9:27:37 GMT -5
If the CSV file contains NUL fields it gets confused.
Like, it can not handle
SEQ DATE NAME MIDN SURN BORN DIED CITY 0001,20231201,JOHN,HUGH,JAMES,1960,2020,TORONTO 0002,20210102,JANE,,SMART,1987,,LOS ANGELES 0003,20200118,TROY,M,KIRK,2002,2019,DENVER
It fails to read second record where there is no middle name and year of death.
|
|
|
Post by cryptomen on Jan 2, 2024 9:28:46 GMT -5
If the CSV file contains NUL fields it gets confused.
Like, it can not handle
SEQ DATE NAME MIDN SURN BORN DIED CITY 0001,20231201,JOHN,HUGH,JAMES,1960,2020,TORONTO 0002,20210102,JANE,,SMART,1987,,LOS ANGELES 0003,20200118,TROY,M,KIRK,2002,2019,DENVER
It fails to read second record where there is no middle name and year of death.
|
|
|
Post by Carl Gundel on Jan 2, 2024 11:22:25 GMT -5
If the CSV file contains NUL fields it gets confused. Like, it can not handle SEQ DATE NAME MIDN SURN BORN DIED CITY 0001,20231201,JOHN,HUGH,JAMES,1960,2020,TORONTO 0002,20210102,JANE,,SMART,1987,,LOS ANGELES 0003,20200118,TROY,M,KIRK,2002,2019,DENVER It fails to read second record where there is no middle name and year of death. No program can read a file that is not in the correct format. So, garbage in, garbage out.
|
|
|
Post by tsh73 on Jan 2, 2024 15:20:13 GMT -5
If the CSV file contains NUL fields it gets confused. Like, it can not handle SEQ DATE NAME MIDN SURN BORN DIED CITY 0001,20231201,JOHN,HUGH,JAMES,1960,2020,TORONTO 0002,20210102,JANE,,SMART,1987,,LOS ANGELES 0003,20200118,TROY,M,KIRK,2002,2019,DENVER It fails to read second record where there is no middle name and year of death. Works for me Probably your errors due to LB not reading correctly first line? You can read if separately (and use for whatever you need it) Just save your file as somefile.txt And run this program open "someFile.txt" for input as #readFile line input #readFile, header$ 'read first line separately. It is clearly NOT comma-separated! print header$ while not( eof( #readFile)) 'rest of the lines are comma-separated, reads in OK aLine= aLine+1 inputcsv #readFile, a$(1), a$(2), a$(3), a$(4), a$(5), a$(6), a$(7), a$(8) print aLine;">"; for i = 1 to 8 print tab(4);word$(header$,i),a$(i) next wend
close #readFile
end
Here's my results - no errors, empty values for "MIDN" and "DIED" for record "2" SEQ DATE NAME MIDN SURN BORN DIED CITY 1> SEQ 0001 DATE 20231201 NAME JOHN MIDN HUGH SURN JAMES BORN 1960 DIED 2020 CITY TORONTO 2> SEQ 0002 DATE 20210102 NAME JANE MIDN SURN SMART BORN 1987 DIED CITY LOS ANGELES 3> SEQ 0003 DATE 20200118 NAME TROY MIDN M SURN KIRK BORN 2002 DIED 2019 CITY DENVER
|
|
|
Post by metro on Jan 2, 2024 17:24:36 GMT -5
If the CSV file contains NUL fields it gets confused. Like, it can not handle SEQ DATE NAME MIDN SURN BORN DIED CITY 0001,20231201,JOHN,HUGH,JAMES,1960,2020,TORONTO 0002,20210102,JANE,,SMART,1987,,LOS ANGELES 0003,20200118,TROY,M,KIRK,2002,2019,DENVER It fails to read second record where there is no middle name and year of death. would it be an idea to check the datafile.csv for ",," before importing then simply replace ",," with whatever...
dat$(a)=REPLSTR$(dat$(a),",,",",UNKNOWN,")
|
|