![]() |
![]() |
We are currently migrating this forum over to our HelpSystems domain. Please post all new threads in our new HelpSystems Community Portal. |
![]() |
|
![]() |
AutoMate Discussion | ![]() |
help :
faq :
home
|
||
Latest News:
|
latest topics : statistics |
Topic Title: Tasks to count lines in a text file Topic Summary: Created On: 04/15/2005 02:30 PM Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|||
These tasks count lines in a text file. This first one will handle UNIX and Windows files.
The three different versions (see my other posts) should all correctly handle an empty file (zero lines) or a file whose last line doesn't contain an LF. Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) ------------------------- AutoMate Pro 7.1.1.0 (Medium isolation level) WinXP Home sp3, "Classic Theme", 120 DPI Edited: 05/06/2006 at 10:05 AM by Pete |
|||
|
|||
![]() |
|||
This version is a lot faster, but it doesn't work with UNIX files.
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) ------------------------- AutoMate Pro 7.1.1.0 (Medium isolation level) WinXP Home sp3, "Classic Theme", 120 DPI |
|||
|
|||
![]() |
|||
Also, if the file contains fixed-length records (i.e. every line is the same length), then this is the fastest version of all of them.
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) ------------------------- AutoMate Pro 7.1.1.0 (Medium isolation level) WinXP Home sp3, "Classic Theme", 120 DPI |
|||
|
|||
![]() |
|||
Hey thanks a mill, Pete. Mucho Appreciated!
|
|||
|
|||
![]() |
|||
Awesome!!! Thank You@!@!!!
|
|||
|
|||
![]() |
|||
I acquire the record count in one statement so that I can show a record counter every 100 records within a script. Here the second statement gets the total number of records.
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) |
|||
|
|||
![]() |
|||
This C++ program will allow you to investigate the line terminators when you're having problems with a particular text file.
It will display output such as the following: Null character(s) found on line 1 Lines with only a CR: 0 Lines with only a LF: 0 Lines with CRLF: 2 (It checks for nulls because BASIC's 'Line Input' command will not find the line terminators on lines which contain nulls. Nulls produce incorrect results only when you use the second posted task in this forum topic.) You can compile the .cpp program yourself or simply run the .exe file. You'll want to run it in a DOS box (c m d.exe) and specify a filename (e.g. CheckLineTerminators.exe "C:\My Data File.txt").
------------------------- AutoMate Pro 7.1.1.0 (Medium isolation level) WinXP Home sp3, "Classic Theme", 120 DPI Edited: 08/08/2006 at 11:24 AM by Pete |
|||
|
|||
![]() |
|||
To add to the collection, here's a C++ version that counts lines in a text file. It will put the number of lines in the return code, or -1 if there was an error. You can obtain the return code in a Run action in Automate or whatever.
This version will work with either UNIX or Windows text files. It will undoubtedly be the fastest version of all of them.
------------------------- AutoMate Pro 7.1.1.0 (Medium isolation level) WinXP Home sp3, "Classic Theme", 120 DPI Edited: 08/08/2006 at 11:25 AM by Pete |
|||
|
|||
![]() |
|||
I didn't think of using a zip file this morning, but I just successfully posted the source code and the .exe files inside zip files in my previous two posts.
------------------------- AutoMate Pro 7.1.1.0 (Medium isolation level) WinXP Home sp3, "Classic Theme", 120 DPI |
|||
|
|||
![]() |
|||
Steve,
Are you able to get this to work if the file contains no rows? I can't get this to work in my task when my files are empty - it errors out and won't create the dataset for me to use to list the file count. |
|||
|
|||
![]() |
|||
This was very helpful
thanks Pete! |
|||
|
AutoMate Discussion
» GENERAL » Sample Tasks
»
Tasks to count lines in a text file
|
![]() |
FuseTalk Enterprise Edition v4.0 - © 1999-2021 FuseTalk Inc. All rights reserved.