Need help in sed in lop using csv


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in sed in lop using csv
# 1  
Old 11-25-2012
Need help in sed in lop using csv

Hi All,

I am having csv datafeed file. I need to update the information in html template which has token.

For eg

Datafeed File

Code:
column1,   column2, column3,column4,column5
data1        data2       data3      data4      data5


Html File

Code:
<h2>column1</h2>
<h2>column2</h2>
<h2>column3</h2>
<h2>column4</h2>
<h2>column5</h2>

Out_put Needed

Code:
<h2>data1</h2>
<h2>data2</h2>
<h2>data3</h2>
<h2>data4</h2>
<h2>data5</h2>

Moderator's Comments:
Mod Comment edit by bakunin: Please view this code tag video for how to use code tags when posting code and data - as you have been told when you opened this thread.

Last edited by bakunin; 11-25-2012 at 06:38 AM..
# 2  
Old 11-25-2012
I don't understand what you want. Are you saying that if fields are separated by a combination of spaces and commas that line is to be written to a file named Html File, but input lines that have fields that are separated by one or more spaces are to be written to a file named Out_put Needed?
# 3  
Old 11-25-2012
I need the use sed and replace the html file where token is there with datafeed content in csv.
# 4  
Old 11-25-2012
Quote:
Originally Posted by ranjancom2000
I need the use sed and replace the html file where token is there with datafeed content in csv.
ranjancom2000,
Please look at the 1st posting in this thread again. There is one input file named Datafeed File and two output files named Html file and Out_put Needed. What are the rules for determining the name of the output file to be produced based on looking at a line from your input file?

Unless this is a homework item, why is sed the only available tool?

Why are you saying that your input file is a CSV file when you are using any combination of one or more spaces and commas as field separators? (Especially note that there are no commas in your second input line.) IfDatafeed File was really a CSV file, the output would be something more like:
Code:
<h2>column1</h2>
<h2>   column2</h2>
<h2> column3</h2>
<h2>column4</h2>
<h2>column5</h2>
<h2>data1        data2       data3      data4      data5</h2>


Last edited by Don Cragun; 11-25-2012 at 08:27 AM..
# 5  
Old 11-25-2012
No i have one source file
Quote:
<h2>column1</h2> <h2>column2</h2> <h2> column3</h2> <h2>column4</h2> <h2>column5</h2>
I need the create multiple html file replace the token with sed command

Out_put Needed

Quote:
<h2>data1</h2> <h2>data2</h2> <h2>data3</h2> <h2>data4</h2> <h2>data5</h2>
I have datafeed with 30K products. So it need to create 30k html.pages
# 6  
Old 11-25-2012
Quote:
Originally Posted by ranjancom2000
No i have one source file I need the create multiple html file replace the token with sed command

Out_put Needed



I have datafeed with 30K products. So it need to create 30k html.pages
ranjancom2000,
We seem to have a language barrier. Since I can't figure out what you want to be considered field separators and I can't figure out how you want to name the 30,000 files that you want produced, I won't be able to help you.

I hope someone else in this forum will be able to help you find a solution to your problem.

- Don

PS Note that using QUOTE tags instead of CODE tags only serves to hide information from people trying to help you.

Also note that creating 30,000 files in a single directory is likely to produce very long lookups on many types of filesystems.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What does the sed command here exactly doing to csv file?

I have the following csv file at the path; now using sed command. what is this exactly doing. sed -i 's//,/g' /FTP/LAB_RESULT_CM.csv Thank you very much for the helpful info. (2 Replies)
Discussion started by: cplusplus1
2 Replies

2. Shell Programming and Scripting

Using sed to remove a column from a CSV

I found that the following works to remove the first column in my file when my CSV is delimited with a simple comma: sed -i 's/*,//' file.csv However, I have a new file where the fields are encapsulated with double quotes - general example of file: "Internal ID", "External ID", "Name"... (8 Replies)
Discussion started by: lojkyelo
8 Replies

3. Shell Programming and Scripting

Transposing lines in a csv file with sed

Hi I have a large csv file with lines like below Date,Status,orig,dest,in,out,when,where 2012-01-01 00:30:37,I,48,56,23,98,83,34 2012-06-17 15:00:38,I,72,43,12,65,34,12I will really appreciate if someone can help with a sed script to transpose this to 2012-01-01 00:30:37,I,orig,48... (5 Replies)
Discussion started by: kaf3773
5 Replies

4. Shell Programming and Scripting

awk/sed/something else for csv file

Hi, I have a filename.csv in which there are 3 colums, ie: Name ; prefixnumber ; number root ; 020 ; 1234567 user1,2,3 ; 070 ; 7654321 What I want is to merge colum 2 and 3 that it becomes 0201234567 or even better +31201234567 so the country number is used and drop the leading 0.... (9 Replies)
Discussion started by: necron
9 Replies

5. Shell Programming and Scripting

Merge 2 CSV files using sed

Help in writing a script using sed which updates fileOne with the contents from fileTwo Example: Contents of fileOne 1,111111 2,897823 3,235473 4,222222 Contents of fileTwo 1,111111,A,1,2 4,222222,A,2,2 5,374632,A,3,2 6,374654,A,4,2 Final File should be: 1,111111,A,1,2... (9 Replies)
Discussion started by: NewToSed
9 Replies

6. Shell Programming and Scripting

Using awk/sed in handling csv file.

Please study the below script and the output Script: echo "Minimum ${host} ${process} response time=${min} ms" >> ${OUTDIR}/${OUTFILE}; echo "Maximum ${host} ${process} response time=${max} ms" >> ${OUTDIR}/${OUTFILE}; echo "Average ${host} ${process} response time=${avg} ms" >>... (0 Replies)
Discussion started by: ajincoep
0 Replies

7. Shell Programming and Scripting

Parsing complicated CSV file with sed

Yes, there is a great doc out there that discusses parsing csv files with sed, and this topic has been covered before but not enough to answer my question (unix.com forums). I'm trying to parse a CSV file that has optional quotes like the following: "Apple","Apples, are fun",3.60,4.4,"I... (3 Replies)
Discussion started by: analog999
3 Replies

8. UNIX for Dummies Questions & Answers

Fields in csv files using sed

Hi, I am working right now with a csv file and I want to insert an excel formula say to the 6th column. sample csv file: 1234,lag,0,77,544,,7 1234,lag,222,0,7,,7 at first i used a simple command: sed 's/^\(.\{17\}\)/\1word/' file.csv but the result is this: ... (2 Replies)
Discussion started by: paoie
2 Replies

9. Shell Programming and Scripting

sed *.csv from file > newfile with /n

I have a an output file with a format: something blah1.csv blah2.csv blah3.csv somethingelse and I'm trying to use sed to pull all the *.csv entries out and put them 1 per line on a new file. I can't quite figure out how to write them to a new file with carriage returns, is there a simple way... (8 Replies)
Discussion started by: unclecameron
8 Replies

10. Shell Programming and Scripting

sed csv remove conditionally

Hello, I have many csv file, but I would like to delete lines with some values in a column conditionally. My example look like this, ex1e, ex2g, ex39, pasg, ssg, mrlc, pc, kb, coop -112, -53, -177, 64, 62, 71, 1, 487, 20 -101, -61, -53, 0, 32767, 51, 0, ... (6 Replies)
Discussion started by: Jae
6 Replies
Login or Register to Ask a Question