jenefa
(Fresh Scripter)
2013-10-08 09:00 PM
Capture First Column from CSV file

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 !!!


Glenn BarnasAdministrator
(KiX Supporter)
2013-10-08 09:07 PM
Re: Capture First Column from CSV file

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


jenefa
(Fresh Scripter)
2013-10-08 09:26 PM
Re: Capture First Column from CSV file

Thanks Glenn,
I am trying it now.
will report how it goes.

RJ


jenefa
(Fresh Scripter)
2013-10-08 10:03 PM
Re: Capture First Column from CSV file

Glenn,

Perfect. Thanks Again

RJ