Sponsored Content
Top Forums Shell Programming and Scripting Reading variables from CSV file Post 302370437 by ventris on Wednesday 11th of November 2009 11:18:30 AM
Old 11-11-2009
Reading variables from CSV file

Hi I am using KSH and trying to read variables from a csv file. I've set the IFS=, and it workds. Problem is where one of the values is text containing a comma. For example the following lines exist in my file. How can I read everything between the quotes into a single variable?

APW13812,,1 ,443,"SHOES DONT MATCH- VARYING UPPER MATERIAL, COLOR AND/OR TEXTURES",526502,02 09,07 09,$29.60
APW13881,,1 ,411,"SEPARATION AT TOE OR HEEL, BUMPER ADHESION",526502,04 09,07 09,$29.10

I am using the following loop to read the variables:
Code:
 
cat file.csv | while IFS=, read var1 var2 var3 etc
do
  do something
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

reading variables from a file

Hi, Could anyone help me in understanding what I am missing.. I have a text file with the following info. INFILE=> #Name Variable=<value> #--------------------------------- name1 inargs="-a Filename1.$VAR.csv -f Filename2.$VAR.csv -c File.c" name1 ... (4 Replies)
Discussion started by: ttshell
4 Replies

2. Shell Programming and Scripting

Script for reading .csv file

Can someone please help me to write script for following scenario : 1> script should read a input .csv file of format : EmpName, PF, Leave, Basic ,HRA 2> another config file ( may be again a .csv file ) has format EmpName and EmpID 3> script should read another config file for each EmpName in... (3 Replies)
Discussion started by: creativeworld
3 Replies

3. Shell Programming and Scripting

reading from a .csv file

Hi , Can anyone please help me to read the value from the .csv file? This is my .csv file: dirnames: first,second i want to get the two names and create directories correspondingly (1 Reply)
Discussion started by: novice_user
1 Replies

4. UNIX for Advanced & Expert Users

Issue reading csv file

HI All I have csv file containing the data like this Electrical Equipment,ElecEquip "Engineering, Machinery & Equipment",Engineerin Entertainment & Broadcasting,Entertain The first and third record are fine,The issue with second records as it has comma enclosed with in inverted... (1 Reply)
Discussion started by: mohdtausifsh
1 Replies

5. Shell Programming and Scripting

Reading variables from a file

Hi, I have an issue that hope someone will be able to help me with.... I'm using a while-read loop to read lines from a file that contain variables, and I want the variables substituted, but I can't get it to work - the below example with explain: while read line do echo $line ... (5 Replies)
Discussion started by: AndyG
5 Replies

6. Shell Programming and Scripting

Reading from a CSV and writing in same CSV file

Hi, I am tryng to read from a csv file and based on some grep command output I will modify one of the column in the same csv. Example:- Input CSV:- 20120829001415,noneAA,google.com 20120829001415,dfsafds,google.com 20120829001415,noneAA,google.com Intermediate Step:- If 2nd column of... (3 Replies)
Discussion started by: kmajumder
3 Replies

7. Shell Programming and Scripting

Reading a csv file using shell script

Hello All, I have a csv file that looks like below ProdId_A,3.3.3,some text,some/text,sometext_1.2.3 ProdId_B,3.3.3,some text,some/text,sometext_1.2.3 ProdId_C,3.3.3,some text,some/text,sometext_1.2.3 ProdId_A,6.6.6,some text,some/text,sometext_9.9.9 I will get ProdId from... (5 Replies)
Discussion started by: anand.shah
5 Replies

8. Shell Programming and Scripting

Reading last line of a CSV file

Hi I have a file which I am reading line by line and processing it. But the last line is not getting read in the file loop until I put an enter in the end. #!/bin/ksh -p v_org_id=${P1} FILE=${P2} NEW_FILE_NAME=$APPLPTMP/b1.txt BAKIFS=$IFS IFS=$'\n' exec 0<"$FILE" echo "File to be... (2 Replies)
Discussion started by: Chinky23
2 Replies

9. Shell Programming and Scripting

Reading the value of particular column from csv file

Hi Folks, I have the below csv file which is comma delimited , now from this file i need to read the value of the column der_id and then want to create a separate text file which will contain the value of the column der_id only please advise how to read the value of the column der_id and then... (3 Replies)
Discussion started by: punpun66
3 Replies

10. Shell Programming and Scripting

Reading CSV file

Hi experts, Im having csv file with few columns which should contain data as shown below. Want to check if column 3 contain row with duplicate value(9876,9876) then corresponding to this in col2 should contain text "tax" and should not contain text "non". Word "non" can come but if in column3... (2 Replies)
Discussion started by: as7951
2 Replies
pilot-addresses(1)					      General Commands Manual						pilot-addresses(1)

NAME
pilot-addresses - read and write address book databases to and from a Palm handheld device, such as those made from Palm, Handspring, Han- dera, TRGPro, Sony or other Palm Compatible Handheld PDA device SYNOPSIS
pilot-addresses -p <port> [-c category ] [-d category ] [-r file | -w file ] (Note that some options are not shown above) DESCRIPTION
pilot-addresses allows the user to read all entries in the Palm address book database, write new entries into the database, and delete a category or delete all entries in the database. TARGET DEVICE
The default serial device used to communicate with a Palm is /dev/pilot. If the environment variable $PILOTPORT is set, its value will override the default. A serial device specified on the command-line will be used regardless of any $PILOTPORT setting. OPTIONS
Several options exist, including... -p --port <port>, Use device file port to communicate with the Palm handheld device. If this is not specified, will look for the $PILOTPORT environ- ment variable. If both are not found, will fall back to /dev/pilot. -h --help Display help synopsis for pilot-addresses -v --version Display version of pilot-addresses -a Augments fields in address book records with additional information. The augmented information is placed before and separated from the field with a semi-colon, (;). Augmented information includes: category_name - placed in front of each record or ["Work" | "Home" | "Fax" | "Other" | "E-mail" | "Main" | "Pager" | "Mobile" ] - placed in front of each phone number field. Empty fields are not augmented. -c category Install records to category category by default. Normally pilot-addresses uses Unfiled as the default category. This option is over- ridden by the category specified in the record with the -a option. -d category Delete all records in the specified category before installing new records. -D Delete all address book records in all categories. Obviously, be very careful with this one. -e Escape all special characters with a backslash. This enables you to read and write entries with newline characters in a field or note. -q Causes pilot-addresses to be quiet and not prompt you to press the HotSync button. -r file Reads records from file and install them to the Palm address book database. (Use the -w file to get a template file for input records.) -t delim Include category in each record, use the delimiter specified to separate all fields of a record. Delimiters are specified as fol- lows: 3=tab, 2=;, 1=,. This overrides the default delimiter of comma between fields and semi-colon between a field's augmented information. (Please note that this may generate confusing results when used with the -a option.) -T Write a header line with field titles as the first line of the data file. -w file Get all address book records from the Palm address book database and writes them into file USAGE
The program will connect to a target device and port, prompt the user to HotSync, and perform the requested read or write operation speci- fied by the user. EXAMPLES
To write all address records in a Palm to the file addrbook.csv: pilot-addresses -w addrbook.csv or pilot-addresses -p /dev/irnine -w addrbook.csv To read the address book records in the file addrbook.csv and install them on a Palm: pilot-addresses -r addrbook.csv To read the address book records in the file addrbook.csv and place them into the Palm address book database category Special after first deleting all current records in the Special category on the palm: pilot-addresses -c Special -d Special -r addrbook.csv SEE ALSO
pilot-link(7) KNOWN BUGS
pilot-addresses has no known bugs. REPORTING BUGS
Report bugs at http://bugs.pilot-link.org/ AUTHOR
pilot-addresses originally written by Kenneth Albanowski, manual page was written by Robert Wittig <bob.wittig@gt.org>. Free Software Foundation Palm Computing Device Tools pilot-addresses(1)
All times are GMT -4. The time now is 09:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy