Showing posts with label LAMP. Show all posts
Showing posts with label LAMP. Show all posts

Friday, 13 September 2019

LAMP csv2tsv

Convert exported LAMP files from CSV to TSV for import into Excel

When working with LAMP (Loop-mediated isothermal amplification) data exported from the Eiken LA-500 machine I needed to import it into the none-American version of Excel. For this I wrote a little script to convert the CSV file into a TSV file.


@echo off
set infilename=%~n1
echo infilename ist: %infilename%
set infileext=%~x1

echo infileext ist: %infileext%
set infilefullpath=%~f1
echo infilefullpath ist: %infilefullpath%
set infilepath=%~p1
echo infilepath ist: %infilepath%
set infiledrive=%~d1
echo infiledrive ist: %infiledrive%

echo Looking for: %infiledrive%%infilepath%%infilename%.tsv.txt
if exist "%infiledrive%%infilepath%%infilename%.tsv.txt" goto file_exists
:: make working copy
copy %1 %tmp%\csv2tsv.tmp

:SED
:: replace in-place comma with tab
sed.exe -i "s/,/\t/g" %tmp%\csv2tsv.tmp
:: replace in-place full stop with comma
sed.exe -i "s/\./,/g" %tmp%\csv2tsv.tmp
:: copy final file to destination
copy %tmp%\csv2tsv.tmp "%infiledrive%%infilepath%%infilename%.tsv.txt"
:: cleanup tmp-file
del /Q %tmp%\csv2tsv.tmp
::
echo Done replacing commas with tabs and full stops with commas.
echo Enjoy your new tsv-file. :)
goto End

:file_exists
echo.
echo The file %infiledrive%%infilespath%%infilename%.tsv.txt allready exists! Aborting!
sleep 3
goto End

:End
echo.
echo The End!
sleep 1
::pause
goto :eof