Page 1 of 1 1
Topic Options
#207885 - 2013-10-08 09:00 PM Capture First Column from CSV file
jenefa Offline
Fresh Scripter

Registered: 2013-02-01
Posts: 15
Loc: USA
Hello all,
Now, i have CSV file and it has 4 columns,
I want to get the First column in a variable without the ","
So, i tried these and could not get it.
$x is the string i have read from the CSV file

$aShareGroup[$Row] = Substr($x, 0, Instr($x, ","))

Need help !!!

Top
#207886 - 2013-10-08 09:07 PM Re: Capture First Column from CSV file [Re: jenefa]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
The CSV UDF will convert between a CSV string and an array. Download it and include it in your script.

Then - $aRecord = CSV($Row) will convert your $Row record to an array. Each field from the CSV will be an element of $aRecord - 0 through 3. $aRecord[0] the first field, $aRecord[1] the second, and so on..

Thinking you can be 100% successful by trying to locate or find commas will get you into trouble. CSV is a specific format, and the CSV() function follows all rules to convert between an array and CSV string.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#207888 - 2013-10-08 09:26 PM Re: Capture First Column from CSV file [Re: Glenn Barnas]
jenefa Offline
Fresh Scripter

Registered: 2013-02-01
Posts: 15
Loc: USA
Thanks Glenn,
I am trying it now.
will report how it goes.

RJ


Edited by RajeshJohn (2013-10-08 09:27 PM)

Top
#207889 - 2013-10-08 10:03 PM Re: Capture First Column from CSV file [Re: jenefa]
jenefa Offline
Fresh Scripter

Registered: 2013-02-01
Posts: 15
Loc: USA
Glenn,

Perfect. Thanks Again

RJ

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.051 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org