Flat File - Comma Delimited


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Flat File - Comma Delimited
# 1  
Old 09-09-2011
Flat File - Comma Delimited

I have a flat file whose contents are comma delimited and there are 84 columns in total, so everytime I try to view the contents, things get over lapped it becomes diffcult to read through the result set.

Is there a command / what would be the best way...if I want to view the results alligned properly and also within my page width?

I hope my explanation is clear....please see an example output of two rows below:

Code:
"1314406694490880000","1","","1d954bd2f796967ce137892afd0b642e","","2011-04-08 19:59:00.0","1","00:00:20","www.homedepot.com","100K","$500M - 1B","Wholesale  Distribution","Unknown","Unknown","Unknown","27","","","","http://www.asterdata.com","","0"
"1314406694490880001","1","","1d954bd2f796967ce137892afd0b642e","","2011-04-08 19:59:00.0","2","00:00:09","www.homedepot.com","100K","$500M - 1B","Wholesale  Distribution","Unknown","Unknown","Unknown","27","","","","http://www.asterdata.com","","0"



I want this to be alligned as something like this:

Code:
"1314406694490880000",   "1",   "1d954bd2f796967ce137892afd0b642e"
"1314406694490880001",   "",     "1d954bd2f796967ce137892afd0b642e"


Last edited by radoulov; 09-09-2011 at 12:42 PM.. Reason: Code tags, please!
# 2  
Old 09-09-2011
If the line is longer than your page size then you will have difficulties to put one line into one terminal line Smilie

Try something like

Code:
awk -F, '{printf ("%s\t%s\t%s\n", $1, $2, $3)}' your_file_here

best regards
Andreas
This User Gave Thanks to danimath For This Post:
# 3  
Old 09-09-2011
increase the terminal width

Code:
 
stty cols 250

---------- Post updated at 12:24 PM ---------- Previous update was at 12:23 PM ----------

i guess she needs the entire line, but the word wrap should not happen in terminal
This User Gave Thanks to itkamaraj For This Post:
# 4  
Old 09-09-2011
Maybe so?
Code:
#!/bin/sh

# read input from stdin

temp=/tmp/$$.html

cat <<END >$temp
<html>
<head><title>Maybe so?</title></head>
<body>
<table>
END

awk -F,  '
{ 
  gsub("\"", "")
  print "<tr>"
  for (i=1; i<=NF; i++)
      printf "<td>%s</td>", $i
  print "</tr>"
}'  >>$temp

echo '</table></body></html>' >>$temp
xdg-open $temp
sleep 5
rm $temp

This User Gave Thanks to yazu For This Post:
# 5  
Old 09-09-2011
thank you so much for all the replies....thank you Andreas, you gave me exactly what I was looking for...thank you again!

-Pri
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Modify comma delimited file columns.

Please help me to update a file which contains date values as below:- From:- "1912108",20161130,"2016-12-01-00.00.00.000000","2016-12-01-08.37.12.000000" "1912108",20161201,"2016-12-02-00.00.00.000000","2016-12-02-08.28.22.000000" To:- "1912108",2016-11-30,"2016-12-01... (7 Replies)
Discussion started by: KrishnaVM
7 Replies

2. Shell Programming and Scripting

Help/Advise please for converting space delimited string variable to comma delimited with quote

Hi, I am wanting to create a script that will construct a SQL statement based on a a space delimited string that it read from a config file. Example of the SQL will be For example, it will read a string like "AAA BBB CCC" and assign to a variable named IN_STRING. I then concatenate... (2 Replies)
Discussion started by: newbie_01
2 Replies

3. Shell Programming and Scripting

Need a script to convert comma delimited files to semi colon delimited

Hi All, I need a unix script to convert .csv files to .skv files (changing a comma delimited file to a semi colon delimited file). I am a unix newbie and so don't know where to start. The script will be scheduled using cron and needs to convert each .csv file in a particular folder to a .skv... (4 Replies)
Discussion started by: CarpKing
4 Replies

4. Shell Programming and Scripting

Comma delimited file manipulation

Question about how to change the first & last name in column one & two so that the names have a capital letter for just the first letter. Example: asdf@asdf.com,asdf,asdfasdf,176.23.22.345,4/12/2012 changed to: asdf@asdf.com,Asdf,Asdfasdf,176.23.22.345,4/12/2012 Thank you kindly, Nick (2 Replies)
Discussion started by: nickytcom
2 Replies

5. Shell Programming and Scripting

Read from Multiple character delimited flat file

Hello Guys I have a multiple character delimited flat file "|~|". when I tried to read the data the "|" character also coming Example I/P file 9882590|~|20111207|~|K03501000063005574033961|~|K|~| Command to get the second column I used awk -F"|~|" ' {print $2}' ... (2 Replies)
Discussion started by: Pratik4891
2 Replies

6. Shell Programming and Scripting

Urgent - Comma delimited file comparision.

Query: There are two files as below – /home/rgupta/input/file.txt.arch (source file) /home/rgupta/output/file.txt (destination file) Files details are attached for the reference. Scenario: File /home/rgupta/input/file.txt.arch picked up by an application xyz. Application xyz does... (1 Reply)
Discussion started by: ravigupta2u
1 Replies

7. UNIX for Dummies Questions & Answers

Comma delimited file

Hi All, I have output of sql saved in comma separated file. Now i need to read line by line this file and assign word to a unix variable for further processing Eg: Test file world, 1, 3, 4 earth,2,3,4,5 moon,1,2,3,4 Output should be word1= world word2=1 echo " first word... (7 Replies)
Discussion started by: gwrm
7 Replies

8. UNIX for Dummies Questions & Answers

Sort the fields in a comma delimited file

Hi, I have a comma delimited file. I want to sort the fields alphabetically and again store them in a comma delimited file. For example, My file looks like this. abc,aaa,xyz,xxx,def pqr,ggg,eee,iii,qqq zyx,lmo,pqr,abc,fff and I want my output to look like this, all fields sorted... (3 Replies)
Discussion started by: swethapatil
3 Replies

9. Shell Programming and Scripting

Converting Tab delimited file to Comma delimited file in Unix

Hi, Can anyone let me know on how to convert a Tab delimited file to Comma delimited file in Unix Thanks!! (22 Replies)
Discussion started by: charan81
22 Replies

10. Shell Programming and Scripting

Comma Delimited file

I have a comma delimited file that sometimes has addresses details in. The problem is that the address detail can be seen as: "Sample House, Sample Road". When I run a script specifying the file is comma delimited I would like it to ignore comma's that are in between speech marks. Is this... (2 Replies)
Discussion started by: dbrundrett
2 Replies
Login or Register to Ask a Question