Update to Rigol CSV to OLS file conversion post

A couple years ago I posted some information on how to convert a Rigol CSV to an OLS File.

I recently got a request for some more information.

So let’s look at the two files

First twenty lines of the Rigol CSV

X,D15-D8,D7-D0,
Second,
-2.61762e-03,30,c0,
-2.61761e-03,30,c0,
-2.61760e-03,30,c0,
-2.61759e-03,30,c0,
-2.61758e-03,30,c0,
-2.61757e-03,30,c0,
-2.61756e-03,30,c0,
-2.61755e-03,30,c0,
-2.61754e-03,30,c0,
-2.61753e-03,30,f0,
-2.61752e-03,30,f0,
-2.61751e-03,38,f0,
-2.61750e-03,38,f0,
-2.61749e-03,38,f0,
-2.61748e-03,38,f0,
-2.61747e-03,3e,f0,
-2.61746e-03,3e,f0,
-2.61745e-03,3e,f0,

First twenty lines of the OLS ouput file

;Rate: 100000000
;channels: 16
0000@1
0000@2
30c0@3
30c0@4
30c0@5
30c0@6
30c0@7
30c0@8
30c0@9
30c0@10
30c0@11
30f0@12
30f0@13
38f0@14
38f0@15
38f0@16
38f0@17
3ef0@18

So you should be able to visibly see the differences without even looking at the specs

  • Headers are different
  • Rigol has a time stamp as the first column of the CSV (relative to the trigger point)
  • Rigol has comma-separated columns
  • OLS has an “@<samplenumber> at the end

So as you can see, this is a simply moving text around and putting it in the right place. Linux is especially suited to these types of tasks, which is why I chose it over Windows. Right OS for the right job. There’s no perfect OS.

Linux is suited because of it’s excellent set of individual tools that can be chained together using pipes to achieve multiple transformations, all on the same line.

So let’s look at the linux commands and “take it apaaaaaarrrt.” (for you eevblog’ers)

cat NewFile0.csv: Use the NewFile0.csv as the starting point aka input file, let’s look at one line at time.

cut -d , -f 2,3 -s: Use a comma to delineate the columns, and output just columns 2 and 3 (ie the high order byte, and low order byte). The “-s” tells us to not include lines not containing commas.

nawk ‘{print $0″@”FNR}’: This gets us the “@” sample number, which is just a constantly increasing number.

tr -d ‘\r’ | tr -d ‘,’: Remove the carriage returns, and the still remaining commas produced from the “cut” above.

sed -e “s/ 0/00/” >NewFile0.ols: Replace ‘ 0′ with ’00’ because that’s how OLS needs them. Output the results to a file called .ols. The space before the first zero is very important because it could modify other lines unintentionally!

Example without the “sed” above: “3e 0@662
Example with:”3e00@662

I welcome comments below!

 

 

About the author

keith

Amateur Electronics Design Engineer and Hacker

One Comment