Hello PB users,
Is there a simple (native) way to read in a comma delimited csv file with PB? In another language they had inputto which allowed you to give it a character for the delimiter.
Or do I have to do it the hard way and parse each line?
Thanks again.
			
			
									
									Reading delimited CSV files
- 
				PB&J Lover
 - Enthusiast

 - Posts: 212
 - Joined: Fri Apr 22, 2005 2:07 pm
 - Location: U.S.A.
 - Contact:
 
Reading delimited CSV files
-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
						Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
- 
				PB&J Lover
 - Enthusiast

 - Posts: 212
 - Joined: Fri Apr 22, 2005 2:07 pm
 - Location: U.S.A.
 - Contact:
 
Yes, I did know to use that. I was just asking if there was a way to read in a delimted file directly. But this will work. Thanks.
			
			
									
									-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
						Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
- 
				PB&J Lover
 - Enthusiast

 - Posts: 212
 - Joined: Fri Apr 22, 2005 2:07 pm
 - Location: U.S.A.
 - Contact:
 
Well, no. First I have to read in the string, then I set up a parcing routine with with FindString() but I'll also have to move the position variable for each find.
A direct method would be:
Where "inputto$" reads the delimited file directly into a variable as a loop advances the index (this sort of thing is very PB-like).
But I can set up the parcing routine for each line read in.
Thanks.
			
			
									
									A direct method would be:
Code: Select all
A$(x) = inputto$(#File,Delimiter$)But I can set up the parcing routine for each line read in.
Thanks.
-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
						Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
That would be good.
If PureBasic implemented a "split" function, creating arrays from char delimited strings, it would be good too, and much faster than doing this through a countfield/stringfield loop process.
And (on a roll) allowing the seperator to be longer than one char would also be good!
			
			
									
									If PureBasic implemented a "split" function, creating arrays from char delimited strings, it would be good too, and much faster than doing this through a countfield/stringfield loop process.
And (on a roll) allowing the seperator to be longer than one char would also be good!
@}--`--,--  A rose by any other name ..
						I've dealt with loading CSV files a few times before, i would post my code for you, but i'm at work and it's at home >.<
Anyhow, what would be really awesome is a version of the php explode command for PB. it is so much more usefull than *just* csv files.
			
			
									
									Anyhow, what would be really awesome is a version of the php explode command for PB. it is so much more usefull than *just* csv files.
--Aszid--
Making crazy people sane, starting tomorrow.
						Making crazy people sane, starting tomorrow.

