Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-19-2008, 03:25 AM   #16
LQ Newbie
Registered: Sep 2008
Posts: 10

Original Poster
Rep: Reputation: 0

Originally Posted by jan61 View Post

I'd assume you have a syntax error at another part of your script. Did you try the script without the END section?

The script works fine with the original END loop provided by PTrenholme. Tinkering with it, it appears that when I moved the code around I inadvertently removed some brackets, so the culprit was this part of the line:
(Record[i,"Name"]!="" ? ", " Record[i,"Name"] : "")
Silly me!

Now it runs, but it seems to give me ALL of the fields instead of just the ones I want ($1, $9 split, $10, $11, $12, $13, $14, $15), the Address array element seems to hold the entire rest of the record. Hmm. Not really sure why this is happening. I will continue to tinker.

EDIT: Ah, I think I see why Address contains so much data. The original input file specification has changed, it contains many fields per record but it is still just the fields I mentioned ($1, $9 - 15) that I want, the rest can be ignored. Just noting this as an update to the original problem.

Last edited by jonnymorris; 09-19-2008 at 04:18 AM.
Old 09-19-2008, 06:14 AM   #17
LQ Newbie
Registered: Sep 2008
Posts: 8

Rep: Reputation: 0
Perl is better


open(DAT, $csv_file) || die("Could not open $csv_file!");

foreach $csv_record (@raw_data)
  print "$f_name\t$l_name\t$age\n";

Example comma separated file. If you want to change it... lets say not comma, but semicolon, just replace it in the split function like this

Remember to use backslash, if you are going to use dot, slash or some other special symbol.

One backslash for backslash and one backslash for escape character.

$ mufile.csv


csv, file, manipulation, text

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing two csv files and write different record in third CSV file irfanb146 Linux - Newbie 3 06-30-2008 09:15 PM
separating a comma delimited line mrobertson Programming 7 07-27-2005 01:56 PM
Sed(?); Appending a comma-delineated file ice_hockey Linux - General 2 05-27-2005 08:42 AM
Comma-Delimited Website Filenames Apocalypse General 1 11-09-2003 09:05 AM
comma delimited file cdragon Programming 5 06-21-2002 07:55 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:23 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration