View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1245_] Rick Rothstein \(MVP - VB\)[_1245_] is offline
external usenet poster
 
Posts: 1
Default import multiple text files into single sheet separate column

I am afraid I am still not sure exactly what you have or want. Let's see if
I can get you to help me understand exactly what you have/need...

You have 200 or so text files in a single, known directory, right? Each of
those files contains several lines of data... can you list the first, say, 5
lines of data from a typical file? Then, can you indicate what part (or is
it all) of, say, the 3rd line from this listing that you want to place in a
column of your spreadsheet?

Rick



"Jootje" wrote in message
...
Hmm

Maybe it's an idea to put the txt files into multiple sheets in one
workbook
and then merge all the worksheets into a single worksheet?


"Jootje" wrote:

1.
The majority of the files start with a number because they represent the
factor I tried to identify from a legal decision. So yes, '1 totaal.txt',
and
the file representing factor 2 that gives the total of all identified
cases
with the factor present in it is named: 2 totaal.txt or sometimes the
name of
the factor is in it like: '8 complainant businessman.txt'.

Totaal is dutch for total btw...my research data is in english however

I picked a few files randomly:

1 totaal.txt
2 totaal.txt
7 totaal author complainant + compl authored.txt
70 geographical identifiers.txt
76 TOT indications of source and geographical indications.txt
177 multiple respondents II respondent 2.txt
187 complaint deficient POS.txt
195a geen verweer respondent.txt
196 supplemental filings.txt
210 TOTAAL TRUE 3-panel 435.txt
231 legal considerations.txt
235 concurrent court proceedings.txt

2.
My original output files are in .html but I converted them to .txt.
The data in the html files are in a table like this (with URLs and tabs):

N Relevance Result name Size Words count
1 D:\CODAS\alles\ascii\d2001-0263.txt 23 KB 2 085
2 D:\CODAS\alles\ascii\d2000-1267.txt 28 KB 2 424
3 D:\CODAS\alles\ascii\d2001-0156.txt 14 KB 1 309
4 D:\CODAS\alles\ascii\d2000-1824.txt 18 KB 1 686
5 D:\CODAS\alles\ascii\d2000-0410.txt 17 KB 1 618
6 D:\CODAS\alles\ascii\d2000-1378.txt 21 KB 2 047


But the converted files are like this


SoftInform: SearchInform Desktop Enterprise search results


N Relevance Result name Size Words count
1 D:\CODAS\alles\ascii\d2001-0263.txt 23 KB 2 085
2 D:\CODAS\alles\ascii\d2000-1267.txt 28 KB 2 424
3 D:\CODAS\alles\ascii\d2001-0156.txt 14 KB 1 309
4 D:\CODAS\alles\ascii\d2000-1824.txt 18 KB 1 686
5 D:\CODAS\alles\ascii\d2000-0410.txt 17 KB 1 618
6 D:\CODAS\alles\ascii\d2000-1378.txt 21 KB 2 047
7 D:\CODAS\alles\ascii\d2000-0192.txt 8 KB 792
8 D:\CODAS\alles\ascii\d2000-0295.txt 31 KB 2 743
9 D:\CODAS\alles\ascii\d2000-1426.txt 17 KB 1 641
10 D:\CODAS\alles\ascii\d2001-0077.txt 14 KB 1 322
11 D:\CODAS\alles\ascii\d2002-0168.txt 15 KB 1 510

So without the tabs and URl's.





"Rick Rothstein (MVP - VB)" wrote:

A couple of questions...

1. Do your text files all have a common name with a numerical
identifier in
them. For example, the text file you show in your example is named "1
totaal.txt"... aside from the possible misspelling of the word 'total',
do
the other 199 files have a number in front, followed by a space
followed by
the exact text "totaal.txt"? If not, is there a way to identify these
files
in a preferred ordering.

2. Is the content of each text file a series of rows of data consisting
of a
single value?

Rick


"Jootje" wrote in message
...
Hi,

I have a folder with over 200 txt files and I want to put those into
a
single worksheet. Each file should be placed in a different column.
That
is,
file 1 into A2 and file 2 in B2 etc.

The data I want from the txt files concerns only one column. I
recorded a
macro for it.

Workbooks.OpenText Filename:= _
"D:\report files\report files txt\1 totaal.txt" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited,
TextQualifier:=
_
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False,
Semicolon:=False, _
Comma:=False, Space:=True, Other:=False,
FieldInfo:=Array(Array(1,
9), _
Array(2, 1), Array(3, 9), Array(4, 9), Array(5, 9), Array(6,
9),
Array(7, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.SmallScroll Down:=105

I think the point is, with all the macro's found on this newsgroup I
don't
know how to use them or to alter them in my case. Probably change
something
in the merge section? Or maybe not. Maybe a totally different
approach? I
think the solution can be simple, but I don't see it.

Any ideas?
Thanks