Formatting csv file in Unix script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting csv file in Unix script
# 1  
Old 02-17-2011
Formatting csv file in Unix script

Hi,

Am using the following command to create a csv file
Code:
paste File_1.csv File_4.csv File_7.csv >Out1.csv
paste File_2.csv File_5.csv File_8.csv >>Out1.csv
paste File_3.csv File_4.csv File_9.csv >>Out1.csv

Input Data:
Quote:
contents in File_1.csv:Column 1,,,
contents in File_4.csv:Column 2,,
contents in File_7.csv:Column 3
contents in File_2.csv:Name,Amount,Date,,
contents in File_5.csv:Name,Amount,,
contents in File_8.csv:Name,Amount
contents in File_3.csv:ABC,123,13-02-2010,,
contents in File_6.csv:
ABC,123,,
XYZ,234,,
contents in File_9.csv:
Yes,Yes,,
No,No,,
Expected Output:
Code:
Column 1              Column 2       Column 3
Name Amount Date      Name Amount    Name Amount
ABC 123 13-02-2010    ABC   123       Yes   Yes
                      XYZ   234       No    No

Actual Output:
Code:
Column 1              Column 2      Column 3
Name Amount Date      Name Amount    Name Amount
ABC 123 13-02-2010    ABC   123       Yes   Yes
XYZ 234   No No

Please help with your thoughts on how to display the column 2 correctly when there is no data for column 1.

Thanks,
Meva.
# 2  
Old 02-17-2011
Meva,
Based on your own input data, here are the results of the paste:
Code:
Column 1,,,     Column 2,,,     Column 3,,,
Name,Amount,Date,,      Name,Amount,,   Name,Amount
ABC,123,13-02-2010,,    ABC,123,,       Yes,Yes,,
        XYZ,234,,       No,No,,

The results are not matching with what you saying you receiving.
Could you clarify it?
# 3  
Old 02-18-2011
The expected and the actual output files are in csv format.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Data formatting in CSV file to EXCEL

Hello friends I want to convert an csv file on unix (which is generated by a ETL application) to a formatted excel sheet like .I have roughly like 28 columns 1)All numbers need to be stored as numbers with leading zeros-like format as text for this column to preserve leading zeroes e.g... (6 Replies)
Discussion started by: etldev
6 Replies

2. Shell Programming and Scripting

Help formatting a .csv file

Dear friends, please your help. I got a .csv (comma separated values) file with 61 columns I need to make a script to change the original file into a new one with this actions: Delete Columns: 1,13-20 Change the format of the following columns: 2: '2013-11-07 00:00:00' to '07/11/2013 0:00'... (5 Replies)
Discussion started by: lestatyela
5 Replies

3. Shell Programming and Scripting

Formatting csv file

Hello I wrote a perl script to output a text file filled with ip addresses and ports that i scanned into microsoft excel. Now that the data is in excel my boss wants me to organize the file in csv format such as Server,port,protocol,random,random,random ns1,25,tcp,stuff,stuff,stuff Can... (0 Replies)
Discussion started by: kingbp
0 Replies

4. Shell Programming and Scripting

CSV file horizontal formatting

Hi folks, Please help me with csv file formatting which needs to be done in horizontal fashion. I have data coming in separate files every hour. What I need to do is extract three values into csv file. In the next hour, I need to extract the new values beside the three values which were... (1 Reply)
Discussion started by: vharsha
1 Replies

5. Shell Programming and Scripting

Exporting data as a CSV file from Unix shell script

Friends...This is the first time i am trying the report generation using shell script... any suggestions are welcome. Is there a way to set the font size & color when i am exporting the data from unix shell script as a CSV file ? The following sample data is saved as a .csv file in the... (2 Replies)
Discussion started by: appu2176
2 Replies

6. Shell Programming and Scripting

How to convert a excel file to a .csv file from unix script

Hi I have a excel file in unix machine and have to convert it into a .csv file.I have to do this from a unix script.How do we do this? Thanks Abhinav (3 Replies)
Discussion started by: akashtcs
3 Replies

7. UNIX for Dummies Questions & Answers

Unix script to convert .csv file to.xls format

I have a .csv file in Unix box i need a UNIX script to convert the.csv files to.xls format. Its very urgent please help me. (1 Reply)
Discussion started by: moon_friend
1 Replies

8. Shell Programming and Scripting

Help with formatting a csv file

Hi, Can anyone help me format a csv file. My csv file have 6 columns. the last 2 columns were put on the second row. Here is the sample output: 000584, 200829014,30,PAPER, 4200059000,'DIXIE BOWLS HEAVY DUTY DISPOSABLE 10 OZ 1. How can I put the last 2 columns in the first row,... (1 Reply)
Discussion started by: softwood
1 Replies

9. UNIX for Advanced & Expert Users

Unix Shell Script with output to CSV File

Hi, I have a unix shell script that is outputting results from an SQL query to a *.csv file, using utl_file.put_line. The resulting file is then sent out via e-mail as a mail attachment. The issue I have is that when the mailed attachment is opened in Excel the first column is shown as... (1 Reply)
Discussion started by: heather.morton@
1 Replies

10. Shell Programming and Scripting

Sample Unix script file to convert .xml to .csv

Dear all, Can you send me a script file the changes .xml to .csv file. Thanks, Srinivasa (4 Replies)
Discussion started by: srinivasaphani
4 Replies
Login or Register to Ask a Question