changing csv file contents to file of rows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting changing csv file contents to file of rows
# 1  
Old 05-12-2010
changing csv file contents to file of rows

i have a file a.txt contents as 1,2,3,4,......etc...in a single line, i want to write to another file in rows as
1
2
3
4
5
can u help?
i do not know the length of a.txt
# 2  
Old 05-12-2010
Code:
tr , \\n<infile

# 3  
Old 05-12-2010
using sed
Code:
sed 's/,/\n/g' file_name

# 4  
Old 05-12-2010
Quote:
Originally Posted by posix
using sed
Code:
sed 's/,/\n/g' file_name

If this doesn't work, try
Code:
$ sed 's/,/\
/g' file_name

# 5  
Old 05-12-2010
sed can get cagey when it comes to newlines:

Code:
tr ',' "\n" <file.wri

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get duplicate rows from a csv file

How can i get the duplicates rows from a file using unix, for example i have data like a,1 b,2 c,3 d,4 a,1 c,3 e,5 i want output to be like a,1 c,3 (4 Replies)
Discussion started by: ggupta
4 Replies

2. Shell Programming and Scripting

Place the contents of a .CSV file to an array

Hi, I am trying to place the contents of a .CSV file to an array, but not sure how to do that. Here is my .CSV file content: App,SLA,Job name,Avg start time,Avg run time,Frequency,Downstream apps XYZ,,ABC14345,3:00 AM,00.04.00,Daily,STAMP XYZ,9:00,ABC12345,3:15 AM,00.05.00,Daily,STAMP ... (4 Replies)
Discussion started by: ajayakunuri
4 Replies

3. Shell Programming and Scripting

Store table contents in csv file

I need to write a script to store the contents of a table in a csv file I'm using Toad, it's a Oracle database. (5 Replies)
Discussion started by: ladyAnne
5 Replies

4. Shell Programming and Scripting

Changing file with rows and columns into just 1 column

Hi I need a bash shell script that will take text files with 4 rows and different numbers of columns in each row and convert each one into a text file with just one column. I then subtract 1.5 from each number in the column (I have that part already) The next step after that is I want to have... (10 Replies)
Discussion started by: ac130pilot
10 Replies

5. Shell Programming and Scripting

Deleting rows from csv file

Hello, I am supposed to process about 100 csv files. But these files have some extra lines at the bottom of the file. these extra lines start with a header for each column and then some values below. These lines are actually a summary of the actual data and not supposed to be processed. These... (8 Replies)
Discussion started by: cobroraj
8 Replies

6. Shell Programming and Scripting

Create Multiple files by reading a input file and changing the contents

Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me . Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer. I want to create a mutiple output files with each file having a... (2 Replies)
Discussion started by: bhargavkr
2 Replies

7. Shell Programming and Scripting

[HELP] - Delete rows on a CSV file

Hello to all members, I am very new in unix stuff (shell scripting), but a want to learn a lot. I am a ex windows user but now i am absolutely Linux super user... :D So i am tryng to made a function to do this: I have two csv files only with numbers, the first one a have: 1 2 3 4 5... (6 Replies)
Discussion started by: Sadarrab
6 Replies

8. Shell Programming and Scripting

How to compare contents of two CSV rows

I have been trying to find the answer to this but can't seem to get it. I have two rows, both are CSV files. I want to iteratively compare each field value to the corresponding value in the second file. Example: File 1.txt 1|hello|3.2|AMB||||B File 2.txt 1|hi|3,2|ABC||||C The... (1 Reply)
Discussion started by: axwack
1 Replies

9. Shell Programming and Scripting

Help needed in changing contents of portion of the file

Hi all, I need help on this. I have a file with 4500 bytes. I want to modify the contents of line from 1357 through 3208. 1. Starting 1357, there is 35 occurence of 40 bytes data making it to 2757. 2. The remaining 451 filler with spaces taking it to 3208. Now, the 40 byte data is... (2 Replies)
Discussion started by: jakSun8
2 Replies

10. Shell Programming and Scripting

Need to append file name to all rows in in .csv file

Hi , Can some one help in appending the file name to all the rows in .csv files the current work is like this. This is adding a new line for file name, I need to append file name to all lines in .csv for i in `ls $filename*.csv` do echo "$i" > ./tmpfile cat "$i" >> ./tmpfile mv... (3 Replies)
Discussion started by: Satyagiri
3 Replies
Login or Register to Ask a Question