Page 1 of 1
					
				Reading delimited CSV files
				Posted: Fri Jun 10, 2005 9:33 pm
				by PB&J Lover
				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.
			 
			
					
				
				Posted: Sat Jun 11, 2005 10:08 am
				by Num3
				Command is StringField(String$, Index, Delimiter$)
			 
			
					
				
				Posted: Mon Jun 13, 2005 2:27 pm
				by PB&J Lover
				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.
			 
			
					
				
				Posted: Mon Jun 13, 2005 2:28 pm
				by thefool
				PB&J Lover wrote:I was just asking if there was a way to read in a delimted file directly.
isnt that directly?
 
			 
			
					
				
				Posted: Mon Jun 13, 2005 2:37 pm
				by PB&J Lover
				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:
Code: Select all
A$(x) = inputto$(#File,Delimiter$)
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.
 
			 
			
					
				
				Posted: Mon Jun 13, 2005 2:52 pm
				by Dare2
				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!
			 
			
					
				
				Posted: Mon Jun 13, 2005 3:09 pm
				by thefool
				ah okay misunderstood it.
			 
			
					
				
				Posted: Fri Jun 17, 2005 12:47 am
				by aszid
				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.