Sponsored Content
Full Discussion: CSV file data extraction
Top Forums Shell Programming and Scripting CSV file data extraction Post 302915257 by Don Cragun on Tuesday 2nd of September 2014 02:14:27 AM
Old 09-02-2014
Quote:
Originally Posted by nanduri
Hi

I am writing a shell script to parse a CSV file , in which i am facing a problem to separate the columns . Could some one help me with it.

Code:
IN301330/00001 pvavan kumar limited xyz@ttccpp.com
IN302148/00002 PRECIOUS SECURITIES (P) LTD  viash@yahoo.co.in
IN300239/00000 CENTRE india compay for you pvt ltx ifo@vikas.com
IN301696/000006 yourcomany pvt ltd pavan@pavan.com
IN300095/0000009 mycomany Pvt Ltd vijy@indianov1.com

Output:

Code:
$id=IN301330/00001
$name=Pavan Kumar Limited
$email=xyz@ttccpp.com

Moderator's Comments:
Mod Comment Please use CODE tags of sample input, output, and code.
What you are trying to do is not clear. From what you have shown us, we could guess that what you want to do is:
  1. Ignore everything except the 1st line in your input,
  2. print a line containing $id= followed by the first field in your input line,
  3. print a line containing $name= followed by the contents of the 2nd through the next to the last fields in your input line with the case shifted for the first character in each field and separate each of those fields by a single space character, and
  4. print a line containing $email= followed by the contents of the last field from your input line.
Is this what you want?

If not please provide a complete description of what you are trying to do. And, if more than one line of input is to be processed, show us the complete output that you want (using CODE tags for input and output) for the sample input provided.

Please also get into the habit of always telling us what OS and shell you're using. Different systems have different utilities and many common utilities have additional/different options depending on what OS is being used. And, various shells have some common features, and some very different extensions that aren't available in other shells. Help us help you.

What have code have you tried to solve your problem?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

extraction of data from a text file which follows certain pattern

hi everybody, i have a file, in it I need to extract some data that follows a particular pattern.. For example: my file contains like now running Speak225 sep 22 mon 16:34:05 2008 -------------------------------- ... (4 Replies)
Discussion started by: mohkris
4 Replies

2. Shell Programming and Scripting

Data Extraction From a File

Hi All, I have a requirement where I have to search the file with some text say "Exception". This exception word can be repeated for more then 10 times. Suppose the "Exception" word is repeated at line numbers say x=10, 50, 60, 120. Now I want to extract all the lines starting from x-5 to... (3 Replies)
Discussion started by: rrangaraju
3 Replies

3. Shell Programming and Scripting

data extraction from xml file

I have an of xml file as shown below <?xml version='1.0' encoding='ASCII' standalone='yes' ?> <Station Index="10264" > <Number Value="237895890" /> <Position Lat="-29.5" Lon="3.5" /> <MaxDepth Value="-4939" /> <VeloLines Count="24"> <VeloLine Index="0" > <Depth... (3 Replies)
Discussion started by: shashi792
3 Replies

4. Shell Programming and Scripting

data extraction from a file

Hi Freinds, I have a file1.txt in the following format File1.txt I want to get 2 files from the above file filextra.txt should have the lines which are ending with "<" and remaining lines in the filecompare.txt file. Please help. (3 Replies)
Discussion started by: i150371485
3 Replies

5. Shell Programming and Scripting

FILE_ID extraction from file name and save it in CSV file after looping through each folders

FILE_ID extraction from file name and save it in CSV file after looping through each folders My files are located in UNIX Server, i want to extract file_id and file_name from each file .and save it in a CSV file. How do I do that? I have folders in unix environment, directory structure is... (15 Replies)
Discussion started by: princetd001
15 Replies

6. Shell Programming and Scripting

Data extraction from .txt file

Hey all, i´ve got the following problem: i´m aquiring data with an instrument and i get data in a .txt file. This is how the txt file looks like: Report of AU program poptau F1P=-49.986ppm F2P=-110.014ppm Target directory for serfile: D:/data/Spect500/nmr/Thoma/882 Linear... (17 Replies)
Discussion started by: expikx
17 Replies

7. Shell Programming and Scripting

Data Manipulation on a .csv file

Hallo Friends, I need you help. My file has 5000 or so lines and currently looks like below(sample). Service Type,Origin,Destination,Rate Per Minute,Minimum Charge,Time Based Rate,Time Based From Day,Time Based To Day,Time Based From Time,Time Based To Time,Destination Prefix List,, VoIS... (3 Replies)
Discussion started by: kekanap
3 Replies

8. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

9. Shell Programming and Scripting

Data extraction from .xml file

Hello, I'm attempting to extract 13 digit numbers beginning with 978 from a data file with the following command: awk '{ for(i=1;i<=NF;i++) if($i ~ /^978/) print $i; }' datafile > outfile This typically works. However, the new data file is an .xml file, and this command is no longer working... (6 Replies)
Discussion started by: palex
6 Replies

10. UNIX for Beginners Questions & Answers

Data extraction and converting into .csv file.

Hi All, I have a data file and need to extract and convert it into csv format: 1) Read and extract the line containing string ending with "----" (file sample_linebyline.txt file) and to make a .csv file from this. 2) To read the flat file flatfile_sample.txt which consists of similar data (... (9 Replies)
Discussion started by: abhi_123
9 Replies
All times are GMT -4. The time now is 10:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy