ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how do I concatenate multiple CSV files into one? (https://www.excelbanter.com/excel-discussion-misc-queries/192702-how-do-i-concatenate-multiple-csv-files-into-one.html)

RobinC

how do I concatenate multiple CSV files into one?
 
I have a bunch of single line CSV files (without even new line characters on
the end) that I want to concatenate into a single file, which I then want to
work with in excel.

How can I do this?

Bernie Deitrick

how do I concatenate multiple CSV files into one?
 
Robin,

Put the code below into an otherwise blank workbook, then run the macro, and select the files that
you want to combine when the file selection dialog appears.

HTH,
Bernie
MS Excel MVP


Sub ConsolidateMultipleUserSelectedFiles()
Dim FileArray As Variant
Dim myBook As Workbook
Set myBook = ThisWorkbook

FileArray = Application.GetOpenFilename(MultiSelect:=True)
If IsArray(FileArray) Then
For i = LBound(FileArray) To UBound(FileArray)
Workbooks.OpenText Filename:=FileArray(i), Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
Range("A1").CurrentRegion.Copy myBook.Worksheets(1).Range("a65536").End(xlUp).Off set(1, 0)
ActiveWorkbook.Close False
Next i
End If

myBook.Save
End Sub


"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line characters on
the end) that I want to concatenate into a single file, which I then want to
work with in excel.

How can I do this?




Ron de Bruin

how do I concatenate multiple CSV files into one?
 
Hi RobinC

You can do it also without code if you want
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RobinC" wrote in message ...
I have a bunch of single line CSV files (without even new line characters on
the end) that I want to concatenate into a single file, which I then want to
work with in excel.

How can I do this?


David Biddulph[_2_]

how do I concatenate multiple CSV files into one?
 
Will the method outlined in Example 1 deal with putting each line onto a new
row (which is what I *guessed* the OP may have wanted)?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Hi RobinC

You can do it also without code if you want
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line characters
on the end) that I want to concatenate into a single file, which I then
want to work with in excel.

How can I do this?




Ron de Bruin

how do I concatenate multiple CSV files into one?
 
Yes if the data is one row in every csv file it is one row in Excel when you import the txt file

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Biddulph" <groups [at] biddulph.org.uk wrote in message ...
Will the method outlined in Example 1 deal with putting each line onto a new
row (which is what I *guessed* the OP may have wanted)?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Hi RobinC

You can do it also without code if you want
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line characters
on the end) that I want to concatenate into a single file, which I then
want to work with in excel.

How can I do this?




Dave Peterson

how do I concatenate multiple CSV files into one?
 
Just a curiousity question...

If you open a single CSV file, do things get imported correctly.

That lack of linefeed characters scares me.


RobinC wrote:

I have a bunch of single line CSV files (without even new line characters on
the end) that I want to concatenate into a single file, which I then want to
work with in excel.

How can I do this?


--

Dave Peterson

David Biddulph[_2_]

how do I concatenate multiple CSV files into one?
 
Interesting!

When I tried it, the resulting file had no new line between the input csv
files, and didn't even have a comma or anything, so the first field of the
second file was concatenated with the last field of the first file, and so
on, and when imported into Excel they were all on the same row..

I wonder what I'm doing different from your suggestion?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Yes if the data is one row in every csv file it is one row in Excel when
you import the txt file

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Will the method outlined in Example 1 deal with putting each line onto a
new row (which is what I *guessed* the OP may have wanted)?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Hi RobinC

You can do it also without code if you want
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line
characters on the end) that I want to concatenate into a single file,
which I then want to work with in excel.

How can I do this?




Ron de Bruin

how do I concatenate multiple CSV files into one?
 
Hi David

No problem here with a new test when I use the exact steps from my site
I go to bed now but maybe Dave or ? can help you

If not I reply tomorrow after work


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Biddulph" <groups [at] biddulph.org.uk wrote in message ...
Interesting!

When I tried it, the resulting file had no new line between the input csv
files, and didn't even have a comma or anything, so the first field of the
second file was concatenated with the last field of the first file, and so
on, and when imported into Excel they were all on the same row..

I wonder what I'm doing different from your suggestion?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Yes if the data is one row in every csv file it is one row in Excel when
you import the txt file

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Will the method outlined in Example 1 deal with putting each line onto a
new row (which is what I *guessed* the OP may have wanted)?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Hi RobinC

You can do it also without code if you want
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line
characters on the end) that I want to concatenate into a single file,
which I then want to work with in excel.

How can I do this?



Dave Peterson

how do I concatenate multiple CSV files into one?
 
I really think it depends on what this means:
"(without even new line characters on the end)"

I'm not sure if that means that there is no linefeed, no carriage return or
what.

I do remember having to convert text files that came from a UNIX system so that
each line had the DOS CRLF at the end of each line instead of just the UNIX LF
characters.




Ron de Bruin wrote:

Hi David

No problem here with a new test when I use the exact steps from my site
I go to bed now but maybe Dave or ? can help you

If not I reply tomorrow after work

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

"David Biddulph" <groups [at] biddulph.org.uk wrote in message ...
Interesting!

When I tried it, the resulting file had no new line between the input csv
files, and didn't even have a comma or anything, so the first field of the
second file was concatenated with the last field of the first file, and so
on, and when imported into Excel they were all on the same row..

I wonder what I'm doing different from your suggestion?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Yes if the data is one row in every csv file it is one row in Excel when
you import the txt file

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Will the method outlined in Example 1 deal with putting each line onto a
new row (which is what I *guessed* the OP may have wanted)?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Hi RobinC

You can do it also without code if you want
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line
characters on the end) that I want to concatenate into a single file,
which I then want to work with in excel.

How can I do this?



--

Dave Peterson

David Biddulph[_2_]

how do I concatenate multiple CSV files into one?
 
In my test file I had no CR, LF, trailing comma, or any other delimiter
after the last character of the data. That was my interpretation of
"(without even new line characters on the end)".
--
David Biddulph

"Dave Peterson" wrote in message
...
I really think it depends on what this means:
"(without even new line characters on the end)"

I'm not sure if that means that there is no linefeed, no carriage return
or
what.

I do remember having to convert text files that came from a UNIX system so
that
each line had the DOS CRLF at the end of each line instead of just the
UNIX LF
characters.




Ron de Bruin wrote:

Hi David

No problem here with a new test when I use the exact steps from my site
I go to bed now but maybe Dave or ? can help you

If not I reply tomorrow after work

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Interesting!

When I tried it, the resulting file had no new line between the input
csv
files, and didn't even have a comma or anything, so the first field of
the
second file was concatenated with the last field of the first file, and
so
on, and when imported into Excel they were all on the same row..

I wonder what I'm doing different from your suggestion?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Yes if the data is one row in every csv file it is one row in Excel
when
you import the txt file

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Will the method outlined in Example 1 deal with putting each line
onto a
new row (which is what I *guessed* the OP may have wanted)?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Hi RobinC

You can do it also without code if you want
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line
characters on the end) that I want to concatenate into a single
file,
which I then want to work with in excel.

How can I do this?



--

Dave Peterson




Dave Peterson

how do I concatenate multiple CSV files into one?
 
That matches up with my results, too.

I'd add those CRLF characters at the end of each line -- either in each file or
in the way I'd concatenate them.

David Biddulph wrote:

In my test file I had no CR, LF, trailing comma, or any other delimiter
after the last character of the data. That was my interpretation of
"(without even new line characters on the end)".
--
David Biddulph

"Dave Peterson" wrote in message
...
I really think it depends on what this means:
"(without even new line characters on the end)"

I'm not sure if that means that there is no linefeed, no carriage return
or
what.

I do remember having to convert text files that came from a UNIX system so
that
each line had the DOS CRLF at the end of each line instead of just the
UNIX LF
characters.




Ron de Bruin wrote:

Hi David

No problem here with a new test when I use the exact steps from my site
I go to bed now but maybe Dave or ? can help you

If not I reply tomorrow after work

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Interesting!

When I tried it, the resulting file had no new line between the input
csv
files, and didn't even have a comma or anything, so the first field of
the
second file was concatenated with the last field of the first file, and
so
on, and when imported into Excel they were all on the same row..

I wonder what I'm doing different from your suggestion?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Yes if the data is one row in every csv file it is one row in Excel
when
you import the txt file

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Will the method outlined in Example 1 deal with putting each line
onto a
new row (which is what I *guessed* the OP may have wanted)?
--
David Biddulph

"Ron de Bruin" wrote in message
...
Hi RobinC

You can do it also without code if you want
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line
characters on the end) that I want to concatenate into a single
file,
which I then want to work with in excel.

How can I do this?



--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com