Advertisement

extract chromatographic signals saved in a struc of dirs

Discussions about chromatography data systems, LIMS, controllers, computer issues and related topics.

2 posts Page 1 of 1
Dear all,

I have been trying to program a macro to obtain .csv of the chromatography signals for a set of .D files. I have used a macro from Gasman sent in another (similar/previous) topic.

However, I have some problems. I was able to program it with a simple structure of files, that is:

For example:

C:\Temp\Run1.D
C:\Temp\Run2.D
C:\Temp\Run3.D

Code: Select all


Name MYCSVALL

Local cols,runtime,signal,i,j,k

!************************************
! Create the file with the list

! I couldn't do it like this (I don't know why...):
!ListDir$ = "dir>" + "c:\Temp\list.txt" + " /A:D /B"
!ExecNoWait ListDir$ !Execute a command "ListDir$" in cmd.exe

! I do it with a .bat file saved in \CORE

ChDir "c:\HPCHEM\CORE"
ExecNoWait ListDir.bat

!!!!!! Contents of the .bat file
!!!!!! cd c:\Temp
!!!!!! dir>list.txt /A:D /B

!************************************
! Commands to set CWD as the one where the files are

Open "ListDir.bat" For Input as #4
Input Using #4, "L", FilesDir$ ! Entire line read into string
FilesDir$ = FilesDir$[4:len(FilesDir$)]
ChDir FilesDir$
Close #4

!************************************
! Commands to find the total number of .D files in the directory

Queue$ = FindFile$(GetCWD$() + "\*.D",,",")
TotalFiles = 1
Repeat
   Queue$ = Queue$[Instr(Queue$,",") + 1:len(Queue$)]
   TotalFiles = TotalFiles + 1
Until (Instr(Queue$,",") = 0)

!************************************
        Open "list.txt" For Input as #5
   For k = 1 to TotalFiles
      Input Using #5, "L", FileName$ ! Entire line read into string   
      !Print FileName$      
      File FileName$
      LoadSignal ,"A",, ChromReg
      FileNameSignal$ = "c:\Temp\" + FileName$ + "\Signal"
      !Print FileNameSignal$
      For j=1 to RegSize(Chromreg)
           cols=DataCols (Chromreg[j])
           Open FileNameSignal$ + Val$(j)+".csv" For Output as #6
           Print "Saving " + FileNameSignal$ + Val$(j) + ".csv"
           For i=1 To cols
                runtime = Data (Chromreg[j],0,i)
                signal = Data (Chromreg[j],1,i)
                print#6,runtime,",",signal
           Next i
           Close#6
      Next j
      DelReg ChromReg
   Next k
        Close #5

Print "Finished"

EndMacro

But I would like to get similar results for files structure like this one (e.g.):

C:\Temp\120516\Run1.D
C:\Temp\120516\Run2.D
C:\Temp\120516\Run3.D
C:\Temp\120517\Run1.D
C:\Temp\120517\Run2.D
C:\Temp\120517\Run3.D
C:\Temp\120518\Run1.D
C:\Temp\120518\Run2.D
C:\Temp\120518\Run3.D

I feel I'm fighting against a simple problem but I don't know how to solve it with Chemstation language. Could anyone help me? The main idea is that I want to dig into several directories...

Thanks in advance for your help.
I'm not sure what listdir.bat is doing, but you should be able to get a list of dirs, and then run a for loop through the dirs list, while the for loop for files is nested in the dir loop.

Ace
2 posts Page 1 of 1

Who is online

In total there are 25 users online :: 1 registered, 0 hidden and 24 guests (based on users active over the past 5 minutes)
Most users ever online was 4374 on Fri Oct 03, 2025 12:41 am

Users browsing this forum: Ahrefs [Bot] and 24 guests

Latest Blog Posts from Separation Science

Separation Science offers free learning from the experts covering methods, applications, webinars, eSeminars, videos, tutorials for users of liquid chromatography, gas chromatography, mass spectrometry, sample preparation and related analytical techniques.

Subscribe to our eNewsletter with daily, weekly or monthly updates: Food & Beverage, Environmental, (Bio)Pharmaceutical, Bioclinical, Liquid Chromatography, Gas Chromatography and Mass Spectrometry.

Liquid Chromatography

Gas Chromatography

Mass Spectrometry