Ans_ShrinkThisMALDI File

advertisement
Ans_ShrinkThisMALDI File
Method 1. In QuickBasic, QBasic, Liberty Basic or Visual Basic module something like
this will work.
Statements
What they do
Open “c:\maldi.txt” for input as #1
Open “c:\smaller.txt” for output as #2
While not EOF(1)
Opens a file in root of drive c
Opens an output file in drive c
Do everything until WEND statement
until an End of File is detected.
Start a loop, increment 1, repeats 10
Input x, y data pair
Go to the top of the for-next loop
Print the last thing read in
Return to top of the while loop
Close #1 and #2 files
For i=1 to 10
Input #1, x,y
Next i
Print #2, x,y
WEND
Close
Method 2 (Discovered by students in Mono Group F2004). In Excel, go to ToolsData
AnalysisSampling. Choose the input range, interval and output range. Save the results
to a file that will be smaller.
Method 3 (Discovered by a student, Mandy Cedars) uses VBA inside Excel, rather
efficient for VBA code. Note the use of the MOD function to decimate the file by tens
(which is why they call it decimate, I guess).
Public Sub Smal()
Dim i As Long
For i = 1 To Sheet1.Rows.Count
If ((i Mod 10) = 1) Then
Sheet1.Rows(i).Copy
Sheet2.Rows(i / 10 + 1).PasteSpecial xlPasteAll
End If
Next i
End Sub
Download