Hello -- 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.