Excel / possibly scripting help?

babs

Can't get enough of FH
Joined
Dec 30, 2003
Messages
1,595
I have a folder full of identically formatted txt files, and need to extract information from each of them. What I'm trying to do is get excel (or whatever can do it tbh) to parse each of them and add the contents of a specific line to the end of a spreadsheet/csv systematically.

Does anyone know of a nice easy way to do this?
 

Jupitus

Old and short, no wonder I'm grumpy!
Staff member
Moderator
FH Subscriber
Joined
Dec 14, 2003
Messages
3,398
I've done similar things in the past using excel (although there may be better tools, I admit)... if you can post a little more detail I'll take a look :)
 

sibanac

Fledgling Freddie
Joined
Dec 19, 2003
Messages
824
the question is a bit vague but it sounds like a 3 line python or perl jobby to me

I could prob knock you out a static python script to do it if i have time later tonight or tomorow, tho i would need to know some more details :)
 

kanonfodda

Fledgling Freddie
Joined
Dec 22, 2003
Messages
288
dim fs ' file system object
dim f ' file
dim ts 'text stream
dim lineinfo as string

Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.GetFile(FileName)
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)

Do While ts.AtEndOfStream <> True

lineinfo = ts.readline

if(instr(1,lineinfo,"(textI want)) > 0) then
activecell.text = (text I want) ' set the current cell to this value
cells(<nextrow>, <nextcol>).select ' chance to the next cell
end if

loop

Hope this make sense
 

babs

Can't get enough of FH
Joined
Dec 30, 2003
Messages
1,595
kanonfodda, the problem is that I don't know what text I want, just that I know it's on the 5th line of the file.

Basically, in a little more detail, the files have 5 lines of meaningful information at the top of them, I want to take whatever is on the 5th, and put it on the end of a column in a blank spreadsheet. Then take the next file, and output the 5th line onto the bottom of the previous column.

What I want to end up with is a column, each cell containing the 5th line from it's respective txt file.

The difficulty I see arising is selecting multiple files to do this from.
 

Jupitus

Old and short, no wonder I'm grumpy!
Staff member
Moderator
FH Subscriber
Joined
Dec 14, 2003
Messages
3,398
Babs,

I'll knock something up if I can... you'll need to paste in a text lists of the source file names (dos prompt dir >> list.txt should so this) to make it work...
 

Jupitus

Old and short, no wonder I'm grumpy!
Staff member
Moderator
FH Subscriber
Joined
Dec 14, 2003
Messages
3,398
tis done.

www.dippyworld.demon.co.uk/Files are for you... create a folder on your drive with all the input files in it and put these files in there also... should be self-explanatory but find me on irc or here for any help required :)
 

babs

Can't get enough of FH
Joined
Dec 30, 2003
Messages
1,595
thanks you're a life saver
 

Paradroid

Fledgling Freddie
Joined
Jan 2, 2004
Messages
645
....and I'd like a little script that'll open up all my work emails and reply to them in an informative and timely fashion? Jup? Any chance you could whack something together?



:D


(*Dreaming*)
 

Users who are viewing this thread

Top Bottom