Restored from previous forum. Originally posted by scurrier.
an easy way to load a CSV file example:
file name sean.csv
sean,currier,33,7-23-69
is in the file
commands
opencsv(1,"sean.csv")
readcsvs (1,first$,last$,age,date$)
and maybe a writecsv would be great too
thanks
Sean
an easy way to load a CSV File
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Andre.
An easy way to do this (not tested):
The Write function should be no problem too 
This way I always use lots of my csv files in an absolute flexible way...
Regards
André
*** German PureBasic Support ***
An easy way to do this (not tested):
Code: Select all
Structure person
FirstName$
Name$
Age.b
Date$
EndStructure
NewList Persons.person()
If ReadFile(0,"sean.csv")
Repeat
a$=ReadString()
AddElement(Persons())
Persons()\FirstName$=StringField(a$,1,",")
Persons()\Name$=StringField(a$,2,",")
Persons()\Age=Val(StringField(a$,3,","))
Persons()\Date$=StringField(a$,4,",")
Until Eof(0)
CloseFile(0)
EndIf
; "sean.csv" file must look like:
; sean,currier,33,7-23-69
; ....

This way I always use lots of my csv files in an absolute flexible way...
Regards
André
*** German PureBasic Support ***
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm