Making a program process multipe files and........can I ask for assitance

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
seanm
Posts: 5
Joined: 05 Sep 2020 05:33

Making a program process multipe files and........can I ask for assitance

#1 Post by seanm » 05 Sep 2020 06:03

Hello.
Background.
I have several drones, each creates flight logs in the form of a .txt file and a .DAT file.
I have these stored on computer and wish to go 'through' them.
In their raw form they are not human readable and so a program "CsvView" and or "TXTlogToCSVtool_general" is used to 'translate' them. Those programs work fine but it is a manual process in that each individual flight log has to be uploaded and processed, one at a time. Once the individual flight log has been processed I have the option to output the data as a csv.
With over one thousand 'flight log's this is tedious.
It seems to me that it should be possible to automate the process.

In a very concise nut shell, how do I do this?

In more detail, the flight logs contain details such as the drone's serial number, its 'name', the radio controller' serial number (though sometimes it is missing) etc. and it would be useful, as a means of sorting these logs, if at least the drone's serial number and or 'name' could be added to the name of the original .txt flight log.

Secondly I would very much like to 'copy' one non-empty line from the csv output of each .txt flight logs and add it to a common csv file.

Am I fooling myself?
Thanks

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Making a program process multipe files and........can I ask for assitance

#2 Post by aGerman » 05 Sep 2020 08:33

Without knowing the content of your files and the related format specification I'm afraid we can't help out at all. And in case the "not human readable" means that the data is saved in a binary format a Batch script will most likely not be able to process the content. Only plain text.

Steffen

seanm
Posts: 5
Joined: 05 Sep 2020 05:33

Re: Making a program process multipe files and........can I ask for assitance

#3 Post by seanm » 05 Sep 2020 08:37

Ok and thanks, can you suggest any forums where this sort of thing might be covered?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Making a program process multipe files and........can I ask for assitance

#4 Post by aGerman » 05 Sep 2020 08:46

Well, I don't know what software does generate these files. If you know it then you could try to find specifications of the files. The drones or their brand might have specific forums where you could find those information or where you could ask for it.

Steffen

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Making a program process multipe files and........can I ask for assitance

#5 Post by penpen » 06 Sep 2020 05:02

I searched google for "CsvView", "Manual" and "Documentation"and got the following as the first link:
https://datfile.net/Doc/intro.html.

In the "CsvView Manual" (first item there) you can find the link TXTlogToCSVtool.

In the OP there, it states:
Notice 3: Tool can be also run from command line like this, example:
TXTlogToCSVtool "C:\temp\inputFile.txt" "C:\temp\outputFile.csv" J I G
In case that's what you are looking for, you could use a for-loop to process them all:
Everything else depends on how the data you want to use for naming is stored in detail (which you should provide).


penpen

seanm
Posts: 5
Joined: 05 Sep 2020 05:33

Re: Making a program process multipe files and........can I ask for assitance

#6 Post by seanm » 08 Sep 2020 15:21

Penpen, :D :D :D :D major happy dance, I don't know how many times I have looked at that page on Phantompilots and not realised the significance of what I was seeing. What is the J I G ?
From memory there is a bit of the film Armageddon where Michael Clarke Duncan goes "thankyou, thankyou, thank you", if I have remembered correctly it is appropriate to this moment.

Coincidentally today I discovered there was a manual for CsvView but I hadn't got 'into it'.
Last edited by seanm on 08 Sep 2020 17:00, edited 1 time in total.

seanm
Posts: 5
Joined: 05 Sep 2020 05:33

Re: Making a program process multipe files and........can I ask for assitance

#7 Post by seanm » 08 Sep 2020 16:59

Yes!!!!!!!!!!!! in 8 minutes this

FORFILES /m *.txt /C "TXTlogToCSVtool /c @file @fname.csv"

processed 846 flight logs, absolutely incredible

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Making a program process multipe files and........can I ask for assitance

#8 Post by Squashman » 09 Sep 2020 07:32

seanm wrote:
08 Sep 2020 16:59
Yes!!!!!!!!!!!! in 8 minutes this

FORFILES /m *.txt /C "TXTlogToCSVtool /c @file @fname.csv"

processed 846 flight logs, absolutely incredible
I am still dismayed how users stumble upon FORFILES to use for tasks like this. While it does accomplish the task, a basic FOR command would have sufficed and is normally more efficient and faster.

Code: Select all

FOR %%G IN (*.txt) DO TXTlogToCSVtool "%%G" "%%~nG.csv" 

seanm
Posts: 5
Joined: 05 Sep 2020 05:33

Re: Making a program process multipe files and........can I ask for assitance

#9 Post by seanm » 09 Sep 2020 08:02

From my perspective, as a numpty, it was perhaps because of the pages I found it had the most understandable or best explained help pages etc.
Meaning no offense but I don't speak computer and I get the impression that some help pages are written for those who are fluent in speaking computer, so when a numpty like me comes along we take the first option that is understandable.
Any way I will give your version a go and see if there is a difference and thanks for the code. :)

Just tried
FOR %G IN (*.txt) DO TXTlogToCSVtool "%G" "%~nG.csv"
and it is quicker but it pegs the CPU at 98% whilst it is running and I can't bring any other windows etc. to the fore, so effectively the computer is locked whilst it runs. It also writes every action to the command window which the former did not.
I assume the double %% were for this being run as a batch file but as a simple single line command it wouldn't run with them present so I reverted to the single %

Post Reply