If you run into problems opening any of the LabRadar
.csv files using OpenOffice or another spreadsheet (doing an import
opens in writer not calc), you may need to remove some trash characters
... Microsoft operating systems 'solved' this problem long ago by
ignoring it ...
There probably are other ways to accomplish the same thing using
OpenOffice or LibreOffice or some other program to read, then write the
files, or maybe using the .csv import option with other parameters ...
I got tired of trying that method and 'fixed' it this way.
The following BASH scripts may be run on any Linux or Unix based
computer, or on a Windows based computer running certain software that
allows it to mimic UNIX.
The purpose of the scripts is to clean up the .csv (Comma Separated
Values) files written by the LabRadar, as they contain enough
non-standard characters to prevent the file from being opened as an
input to a spreadsheet under OpenOffice (and apparently LibreOffice as
well).
Once the scripts are run, each .csv file within the LabRadar folder
structure as of spring 2019 will copied to a new file with the name
'Clean.' prepended to the file, in the same directory, thus the
original files are not modified. The size of the files will
double naturally, so doing this on the SD card when a lot of series
files are present may fail. I recommend copying the files from
the SD card to your hard drive before you clean them.
To install these scripts knowledge of UNIX (Linux) is helpful, but not
absolutely necessary. You will need to know how to activate your
terminal command, and knowldge of your computers file system is
mandatory.
One aproach would have you copy the LabRadar SD card completely to an
new empty folder we could call LabRadar that you create somewhere you
have read and write privileges. You can copy the scripts below
into the LabRadar folder, and leave them there. When you copy the
SD card, only copy all of its series folders into your LabRadar
folder. When you run the scripts do so from the LabRadar folder,
by starting the first script with the ./ convention. If you run
the scripts from another folder, call them using their full path name.
Another aproach; If you do not already have a 'Scripts' directory in
your personal file space, create one. Copy the scripts to this
directory, and modify your PATH to include your Scripts
directory. Now you can call the script(s) in terminal from
whatever directory you are in ... so if you save your LabRadar track
data in a folder inside a specific load development directory, you can
leave them there, and run the scripts to clean them up.
And finally, when you are satisfied that the scripts do what they are
supposed to do, and that your Scripts directory is on your PATH
etc. you can (at least if you are running MacOS 10.x) add the
first script 'CleanLabRadarSeriesFolders.sh to the right click
menu in Finder, which will allow you to directly access the cleanup
script from Finder.
The scripts must be placed in folders that are on your $PATH, or the
PATH must be edited to include the location of the scripts, or the
scripts must be called with their own path in the file name. It is
convention (and easiest) to place them in your own ~/Scripts/Shell
folder or equivalent, and ensure that folder is in your $PATH.
To copy the scripts, simply mark the text starting with the line
#!/bin/sh and ending at the last line. Then copy it, and
using a text editor (nano, or something similar) paste the text, and
save the file to the name shown (including the .sh extension).
You can copy these scripts for your own and club use, but please no
commercial use without at least contacting me first
mailto:jsnell6746@gmail.com or through http://snellsnotebook.us, thank
you!
If you don't quite know what you are doing writing scripts, or want a
more detailed explanation or have any questions regarding these scripts
please contact me.
SCRIPTS BELOW
CleanLabRadarSeriesFolders.sh
#!/bin/sh
# CleanLabRadarSeriesFolders.sh
#
# Created by John Snell on 12/31/18.
#
# Find all the 'Series' folders under current directory
# Folder names are SR???? (SR0001 up to SR9999)
# Calls CleanLabRadarDirectory.sh to run UNIX character cleanup on all .csv files
# in this folder and all child TRK folders.
# Calls CleanLabRadarDirectory2.sh to do the work.
# Decends the folder tree to the end iterating the previous steps for each series folder.
#
for name in SR????
do
cd $name
echo "--------------"
pwd
CleanLabRadarDirectory.sh
cd ..
done
CleanLabRadarDirectory.sh
#!/bin/sh
# Previously CleanLabRadarDirectory1.sh
#
# Created by John Snell on 12/31/18.
#
# Takes no parameters
# Finds and cleans all .csv files in current and TRK sub-directory
# Prints current directory name on screen as it decends the folder tree
# Reverts control to the calling program
#
find *.csv -exec CleanLabRadarDirectory2.sh {} \;
cd TRK
echo PWD = $PWD
find *.csv -exec CleanLabRadarDirectory2.sh {} \;
cd ..
echo PWD = $PWD
CleanLabRadarDirectory2.sh
#!/bin/sh
# CleanLabRadarDirectory2.sh
#
# Created by John Snell on 12/31/18.
#
# Called by CleanLabRadarDirectory.sh
# Parameter passed is the filename found by CleanLabRadarDirectory.sh
# Removes OCTAL 11, 12, 15, 40-409 and 176 from (csv) file to make it compatible with
# OpenOffice Spreadsheet. (Native Excel has corrupted csv standards! - AGAIN!)
#
# tr -cd '\11\12\15\40-\176' ... This command uses the -c and -d arguments to the tr command
# to remove all of the characters from the input stream
# ($1 - the file we found in the calling script)other than the ASCII octal values shown between
# the single quotes.
# The command specifically allows the following characters to pass through this filter:
# Octal 11: tab
# Octal 12: Linefeed
# Octal 15: Carriage Return
# Octal 40 through 175: all the 'good' keyboard characters
# And saves the translated file into new file $F ... 'Clean.filename.csv'
# Prints the name of the original file -> translated file to screen.
#
# Reverts control to the calling program.
#
F=Clean.$1
tr -cd '\11\12\15\40-\176' < $1 > $F
echo $1 " -> " $F