Extract Line and Column from CSV Line in ksh or bash format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract Line and Column from CSV Line in ksh or bash format
# 1  
Old 07-12-2012
Extract Line and Column from CSV Line in ksh or bash format

Hi,

I was doing some research and can't seem to find anything. I'm trying to automate a process by creating a script to read a csv line and column and assigning that value to a variable for the script to process it.

Also if you could tell me the line and column if it's on another work book (not sure if this is the correct term, referring to the tabs on the bottom as if you were viewing it in excel)

Is this possible? if it is can i write it with bash or would i need perl?



Thanks!

---------- Post updated 07-12-12 at 10:28 AM ---------- Previous update was 07-11-12 at 10:57 AM ----------

anyone have any advice?
# 2  
Old 07-12-2012
is that value every time on the same line and column?
# 3  
Old 07-12-2012
Hi,

Thanks for answering... no the value will change... basically I'm writing a script to automate a process. I need to script to pull a few lines like lets say Column A line 1 - line 50 for example. but there will be times that it is only 1 or two lines. so i would need it to find those lines and assign them a variable for the script to continue. I think i should be ok to write the script once i have this out of the way but... I'm so confused on how to get that info and assign it a variable. not sure its even possible.
# 4  
Old 07-12-2012
I did a search on Excel in CPAN and found two modules that you could install and then use perl. I've never used either of these before, but, looks like there's modules that could help you out.

Spreadsheet::ParseExcel & Excel::Writer:XLSX

---------- Post updated at 09:57 AM ---------- Previous update was at 09:53 AM ----------

Sorry, maybe I misread your post. Is this a text csv file or is it an excel xls file?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Extract columns based on the first line of each column

Sorry to bother you guys again. I have a file1 with multiple columns like this:gga_miR_100 gga_miR_300 gga_miR_3500 gga_miR_4600 gga_miR_5600 gga_miR_30 gga_miR_500 kj rwg ghhh jy jyu we vf 5g 5hg h6 56h i8 45t 44r4 4bg 4r546 9lgtr (fer) 4fr f433 3feev f4 bf4 35g vfr ge 2rr ... (5 Replies)
Discussion started by: yuejian
5 Replies

2. Shell Programming and Scripting

Column with New Line in CSV file

Hello, Got a CSV file which contains 21 columns Need to convert the file to Pipe delimiter and Few columns text data contains new line Example 1,2,3,"ABC" 8" ABC,5,6,7 1,2,3,"ABC" 8" ABC,5,6,7 ( New Line) 1,2,3,""ABC" 8" ABC", 5,6,7 1,2,3,"ABC" ,5,6,7(New line) Expected... (8 Replies)
Discussion started by: krux_rap
8 Replies

3. Shell Programming and Scripting

KSH or Awk first and last line based on column 2

Example: 10.160.101.160,0707073711,22.203.203.200 10.160.101.160,0707075132,22.203.210.249 10.160.101.160,0707085436,22.203.210.249 10.160.101.160,0707091712,22.203.221.176 10.160.101.160,0707091811,22.203.221.176 10.160.101.160,0707091845,22.203.221.176... (1 Reply)
Discussion started by: BrownBob
1 Replies

4. Shell Programming and Scripting

Need perl or shell script to sort vertical lines to horizontal line in csv format

Need perl or shell script to sort vertical lines to horizontal line in csv format My file like below ------------------------- ================================================================================ PATH PINKY1000#I1-1-ZENTA1000-2#I7-1-ASON-SBR-UP-943113845 ... (4 Replies)
Discussion started by: sreedhargouda.h
4 Replies

5. Shell Programming and Scripting

ksh: how to extract strings from each line based on a condition

Hi , I'm a newbie.Never worked on Unix before. I want a shell script to perform the following: I want to extract strings from each line ,based on the type of line(Nameline,Subline) and output it to another file.Below is a sample format. 2010-12-21 14:00"1"Nameline"Midterm"First Name:Jane ... (4 Replies)
Discussion started by: angie1234
4 Replies

6. Shell Programming and Scripting

Extract first column from second line in perl

Hello Gurus I have a source file which has the first line as header and the rest are the records I need to extract the first column from the second line to extract a value I/P ... (7 Replies)
Discussion started by: Pratik4891
7 Replies

7. Shell Programming and Scripting

Replace 2nd column of CSV file with numbers on line

I have a csv file with occasional multiple entries in the second column. 111111,104,07-24-2011,3.15,N, 222222,020 140,07-24-2011,10.00,N,I want the result 111111,104,07-24-2011,3.15,N, 222222,020,07-24-2011,10.00,N, 222222,140,07-24-2011,10.00,N, I know I can get the output of the second... (5 Replies)
Discussion started by: ffdstanley
5 Replies

8. Shell Programming and Scripting

Remove line feed from csv file column

Hi All, i have a csv file . In the 7th column i have data that has line feed in it. Requirement is to remove the line feed from the 7th column whenever it appears There are 11 columns in the file C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11 The value in C7 contains line feed ( Alt + Enter ),... (2 Replies)
Discussion started by: r_t_1601
2 Replies

9. Shell Programming and Scripting

Remove line feed from csv file column

Hi All, My requirement is to remove line (3 Replies)
Discussion started by: r_t_1601
3 Replies

10. UNIX for Dummies Questions & Answers

read a line from a csv file and convert a column to all caps

Hello experts, I am trying to read a line from a csv file that contains '.doc' and print the second column in all caps. e.g. My csv file contains: Test.doc|This is a Test|test1|tes,t2|test-3 Test2.pdf|This is a Second Test| test1|tes,t2|t-est3 while read line do echo "$line" |... (3 Replies)
Discussion started by: orahi001
3 Replies
Login or Register to Ask a Question