Need help combining txt files w/ multiple lines into csv single cell - also need data merge


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need help combining txt files w/ multiple lines into csv single cell - also need data merge
# 1  
Old 02-04-2013
Question Need help combining txt files w/ multiple lines into csv single cell - also need data merge

SmilieHello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux.

I am working in Linux terminal.

I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine the txt files into a single csv file, with the content from each text file going into a single cell. Maybe I need to use Excel instead of csv, but you get the idea.

I tried accomplishing this using Windows command lines --
copy *.txt combined.csv

the problem with the above is that each line in each .txt file was a separate line and cell in the csv

i am trying to do this in linux now. I tried the following command --
cat *.txt > combined.csv

this command created the combined csv file, but all of the content from the txt files were imported right next to each other, such as the example below, which represents 3 text files (the original content of the txt files is below the combined result):

line 1 I like applesline 2 I like bananasline 3 I like coconuts

original file content:
file1 - line 1 I like apples
file2 - line 2 I like bananas
file3 - line 3 I like coconuts

So my first goal is to actually get these on separate lines in the csv and into their own cell. Then my next goal is to figure out how to do the same thing, except that each file will have 2 to 3 lines in each txt....

if I have a txt file with content on multiple lines and I copy and paste it into Excel by clicking on a cell and then pasting... the lines all end up in a different row (so three lines in the txt file results in 3 rows in the excel file) -- however, if I click on the cell and then click in the Formula Bar at the top and paste it there, then the content is all pasted into a single cell -- this is the result I am trying to accomplish with the linux commands.

Can anyone help me out? I would really be appreciative. Also, the next thing I am trying to figure out how to do is before I actually import all of these files into a csv, I want to run a data merge and use a database to populate the file, here is an example:

Database CSV:
column A (XXX1): sports car
column B (XXX2): Denver
column C (XXX3): Colorado

text file 1 content:
I found a nice XXX1 in XXX2, XXX3.
This XXX1 was very beautiful and sleek.
I drove out of XXX2 in a hurry with my new XXX1.

result after data merge in txt file:
I found a nice sports car in Denver, Colorado.
This sports car was very beautiful and sleek.
I drove out of Denver in a hurry with my new sports car.

Then after data merge, I want to import these txt results into a single cell into a csv.
# 2  
Old 02-04-2013
I'm lost. Is the expected output to have each file's contents to be a separate column?

Code:
file1 line1, file2 line1, file3 line1
file1 line2, file2 line2, file3 line2
file1 line3, file2 line3, file3 line3

If so, please look into the paste(1) utility.
# 3  
Old 02-04-2013
PLEASE use code tags as demanded by forum rules.

I'm lost, too. I guess it's two threads in one? Pls post (for each sub thread) input and output samples, and a comprehensible description of how you expect things to work on input to produce the desired output.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tabbed multiple csv files into one single excel file with using shell script not perl

Hi Experts, I am querying backup status results for multiple databases and getting each and every database result in one csv file. so i need to combine all csv files in one excel file with separate tabs. I am not familiar with perl script so i am using shell script. Could anyone please... (4 Replies)
Discussion started by: ramakrk2
4 Replies

2. Shell Programming and Scripting

Merge multiple lines into a single line

Hi all, I'm relatively new to scripting, I can do pretty basic things. I have a daily log file that looks like: timestamp=2017-06-28-01.01.35.080576; event status=0; userid=user1; authid=user1; application id=10.10.10.10.11111.12345678901; application name=GUI; ... (29 Replies)
Discussion started by: dwdnet
29 Replies

3. Shell Programming and Scripting

How to merge the multiple data files as a single file?

Hi Experts, I have created multiple scripts and send the output to new file, getting this output to my mailbox on daily basis. I would like to send the all outputs to a single file, need to merge all file outputs on a single file. For example, Created script for df -h > df.doc grep... (7 Replies)
Discussion started by: seenuvasan1985
7 Replies

4. UNIX for Advanced & Expert Users

How to extract data from single first cell and copy it notepad?

how to extract data from single first cell and copy it notepad sample source IN EXCEL DD-MM-YYYY LOANNUM LOANPARTID OUTPUT IN NOTEPAD DD-MM-YYYY I WANT ALONE DATE SHOULD BE EXTRACTED FROM EXCEL AND COPY IT IN NOTEPAD CAN ANYONE HELP REGARDING THIS USING SCRIPTS (2 Replies)
Discussion started by: gchandu
2 Replies

5. Shell Programming and Scripting

Combining columns from multiple files into one single output file

Hi, I have 3 files with one column value as shown File: a.txt ------------ Data_a1 Data_a2 File2: b.txt ------------ Data_b1 Data_b2 Data_b3 Data_b4 File3: c.txt ------------ Data_c1 Data_c2 Data_c3 Data_c4 Data_c5 (6 Replies)
Discussion started by: vfrg
6 Replies

6. Programming

PERL:Combining multiple lines to single line

Hi All I need a small help for the below format in making a small script in Perl or Shell. I have a file in which a single line entries are broken into three line entries. Eg: I have a pen and notebook. All i want is to capture in a single line in a separate file. eg: I have a pen and... (4 Replies)
Discussion started by: Kalaiela
4 Replies

7. Shell Programming and Scripting

Compare two csv files by two colums and create third file combining data from them.

I've got two large csv text table files with different number of columns each. I have to compare them based on first two columns and create resulting file that would in case of matched first two columns include all values from first one and all values (except first two colums) from second one. I... (5 Replies)
Discussion started by: agb2008
5 Replies

8. Shell Programming and Scripting

Merge text files while combining the multiple header/trailer records into one each.

Situation: Our system currently executes a job (COBOL Program) that generates an interface file to be sent to one of our vendors. Because this system processes information for over 100,000 employees/retirees (and growing), we'd like to multi-thread the job into processing-groups in order to... (4 Replies)
Discussion started by: oordonez
4 Replies

9. Shell Programming and Scripting

How to remove certain lines in multiple txt files?

Hi , I have this type of files:- BGH.28OCT2008.00000001.433155.001 BGH.28OCT2008.00000002.1552361.001 BGH.28OCT2008.00000003.1438355.001 BGH.28OCT2008.00000004.1562602.001 Inside them contains the below: 5Discounts 6P150 - Max Total Usage RM150|-221.00 P150 EPP - Talktime RM150... (5 Replies)
Discussion started by: olloong
5 Replies

10. Shell Programming and Scripting

need help--script to filter specific lines from multiple txt files

Hi folks, - I have 800 txt files - those files are cisco router configs router1.txt router2.txt ... router800.txt I want to accomplish the following: - I want to have a seperate file with all the filenames that I want to process - I want a script that goes trough all those... (7 Replies)
Discussion started by: I-1
7 Replies
Login or Register to Ask a Question