I have a set of text files named outfile00.txt
until outfile297.txt
. Each file has a number (decimal or otherwise) on every line except the first one (which is like a header).
I need to import the contents of each file to a column starting from column A (which will correspond to outfile00.txt
) until all text files have been imported.
Here is a sample of the beginning of outfile00.txt
:
KP=0.50 ,Ki=0.10 ,Kd=0.05
0.00
0.00
0.00
0.00
The actual file has about 1500 lines. I've tried manually importing the text file using the Data tab; Excel has no issues and the text is imported.
How can I import all the text files as a batch?
EDIT
I believe I had not defined my problem clearly, so here are some extra details.
With regards to cybernard's method,
If I create a tab-separated values file (the tab character is between the letter and number on each line) as follows,
a 1
b 2
c 3
e 4
f 5
g 6
I can import the text file directly and get the following,
I was hoping to create a file similar to the aforementioned TSV file. An example would be as follows,
KP=0.50 ,Ki=0.10 ,Kd=0.05 KP=0.50 ,Ki=0.10 ,Kd=0.10 KP=0.50 ,Ki=0.10 ,Kd=0.15
0.00 117.00 123.00
0.00 118.00 124.00
0.00 119.00 125.00
0.00 120.00 126.00
which produces the following import results,
I need to know how I can generate such a TSV file from my source files.
Best Answer
You can use Power Query to combine all files in a folder. Power Query is a free add-in from Microsoft for Excel 2010 and 2013 and is built into Excel 2016 as Get and Transform.
Ken Puls has a detailed tutorial here.
Once the query is set up, files can be added or removed from the folder and the query can be refreshed with the click of a button.