Solved Help with conversion. COVID-19 help!

October 30, 2020 at 13:07:24
Specs: Windows 7
My laboratory needs help in the fight against COVID-19.
During the analysis process we need a simple way to convert a csv file. I have no experience in programming so I need a finished product.

I want to drop “File name.csv” on the batch file and a “File name_converted.csv” is generated.
The conversion includes:
- Write new headline
- Insert comma between letter and digit in the first column.
The two last columns are variable

Original file:
Destination Well Position (Label),Reagents (no vol),Full (Constituent + Tube) ID
A1,RdRP,Control
B1,RdRP,Water
C1,RdRP,Sample1
D1,RdRP,Sample2
E1,RdRP,Sample3
F1,RdRP,Sample4
G1,RdRP,Sample5
H1,,
A2,,
B2,,
C2,,
D2,,
E2,,
F2,,
G2,,
H2,,
A3,,
B3,,
C3,,
D3,,
E3,,
F3,,
G3,,
H3,,
A4,,
B4,,
C4,,
D4,,
E4,,
F4,,
G4,,
H4,,
A5,,
B5,,
C5,,
D5,,
E5,,
F5,,
G5,,
H5,,
A6,,
B6,,
C6,,
D6,,
E6,,
F6,,
G6,,
H6,,
A7,,
B7,,
C7,,
D7,,
E7,,
F7,,
G7,,
H7,,
A8,,
B8,,
C8,,
D8,,
E8,,
F8,,
G8,,
H8,,
A9,,
B9,,
C9,,
D9,,
E9,,
F9,,
G9,,
H9,,
A10,,
B10,,
C10,,
D10,,
E10,,
F10,,
G10,,
H10,,
A11,,
B11,,
C11,,
D11,,
E11,,
F11,,
G11,,
H11,,
A12,,
B12,,
C12,,
D12,,
E12,,
F12,,
G12,,
H12,,

Converted file:
Row,Column,*Target Name,*Sample Name
A,1,RdRP,Converted
B,1,RdRP,Water
C,1,RdRP,Sample1
D,1,RdRP,Sample2
E,1,RdRP,Sample3
F,1,RdRP,Sample4
G,1,RdRP,Sample5
H,1,,
A,2,,
B,2,,
C,2,,
D,2,,
E,2,,
F,2,,
G,2,,
H,2,,
A,3,,
B,3,,
C,3,,
D,3,,
E,3,,
F,3,,
G,3,,
H,3,,
A,4,,
B,4,,
C,4,,
D,4,,
E,4,,
F,4,,
G,4,,
H,4,,
A,5,,
B,5,,
C,5,,
D,5,,
E,5,,
F,5,,
G,5,,
H,5,,
A,6,,
B,6,,
C,6,,
D,6,,
E,6,,
F,6,,
G,6,,
H,6,,
A,7,,
B,7,,
C,7,,
D,7,,
E,7,,
F,7,,
G,7,,
H,7,,
A,8,,
B,8,,
C,8,,
D,8,,
E,8,,
F,8,,
G,8,,
H,8,,
A,9,,
B,9,,
C,9,,
D,9,,
E,9,,
F,9,,
G,9,,
H,9,,
A,10,,
B,10,,
C,10,,
D,10,,
E,10,,
F,10,,
G,10,,
H,10,,
A,11,,
B,11,,
C,11,,
D,11,,
E,11,,
F,11,,
G,11,,
H,11,,
A,12,,
B,12,,
C,12,,
D,12,,
E,12,,
F,12,,
G,12,,
H,12,,


See More: Help with conversion. COVID-19 help!


#1
October 30, 2020 at 20:41:41
✔ Best Answer
:: --------- sedanbat.bat
@echo off & setlocal
set out=%~n1_converted%~x1%
echo going to file: %out%
pause
>%out% echo Row,Column,*Target Name,*Sample Name
for /f "skip=1 tokens=*" %%a in (%1) do call :xx "%%a"
exit /b

:xx
set line=%~1
>>%out% echo %line:~0,1%,%line:~1%
exit /b
::----------- end script


Reply ↓  Report •

#2
October 31, 2020 at 00:20:11
Wow thanks!

message edited by sedanstr


Reply ↓  Report •
Related Solutions


Ask Question