Rigol RSA3015N Noob question about the .csv data format? - Page 1
Forum section: electronics / testgear

author: curtisound
author_rank: Newbie
timestamp: May 27, 2023, 08:28:37 am
content: I recently got a new Rigol RSA3015N spectrum analyzer that I mostly use for UHF broadcast spectrum scans to coordinate wireless mics and communications equipment. However, The .csv files it generates don't seem to work with my frequency coordination software.With my older TTI PSA2702 spectrum analyzer I can easily import the .csv files of my spectrum traces into my software. Those .csv files look pretty straight forward with real numbers like this example.TTI partial example starting 510 MHz.CSV DATA,0510.0000,-064.70510.1110,-065.40510.2220,-065.50510.3330,-059.80510.4440,-054.50510.5560,-050.10510.6670,-048.30510.7780,-048.20510.8890,-051.9However, The trace file data for the frequency markers of my Rigol RSA3015N's .csv look different. The frequency markers always have "e+08" as part of the frequency data point which I'm guessing is math shorthand for moving the decimal point? (obviously I'm no programmer).I'm guessing there's no setting to change this? I haven't been able to find one. Maybe there is a way to convert the .csv files?Thanks for any insight3015N partial example starting 450 MHz.CSV DATA,4.5e+08,-79.51944.5025e+08,-79.99484.505e+08,-80.92954.5075e+08,-81.17534.51e+08,-81.73384.5125e+08,-82.16994.515e+08,-82.26034.5175e+08,-82.05734.52e+08,-82.1724

author: alm
author_rank: Super Contributor
timestamp: May 27, 2023, 08:46:18 am
content: 4.5e+08 is shorthand for 4.5 * 108. This is not specific to programming: you can find the exact same syntax on most scientific calculators. I would import the data into a spreadsheet like Excel, change the format there, and re-export as csv.

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 27, 2023, 09:37:21 am
content: Yup, it is just standard scientific notation numeric data, an absolutely ubiquitous format.In Linux or macOS, you only need to run e.g.awk -F ',' '{ if (FNR==1 || NF!=2) print ; else printf "%.4f,%.4f\n", $1, $2 } ' <original.csv>fixed.csvto convert the notation to decimal.If you have Bash installed in any OS, runbash -c 'LANG=C LC_ALL=C IFS="," ; ( read H && echo "$H" ; while read A B ; do printf "%.4f,%.4f\n" "$A" "$B" ; done ) <original.csv>fixed.csv'to convert the notation just like above.In Linux, either of the above can be written as a script, with a shortcut that lets you drop files on top of to get them converted. (You can either discard the original data, save the original data to sayoriginal.old, or use e.g. Zenity to pop up a Save As.. dialog for each converted file.)If you have or install Python, it is easy to write a small program that fixes such CSV files. (Python 3 has a built-inCSVmodule, that can read and write CSV files; or one can do the equivalent of the above awk line. Or you can even add a tiny Tcl/Tk user interface, so that when you drop a CSV file on top of the shortcut, the Python interpreter will execute the script, that will simply prompt you where to save the converted file.)I personally don't use Windows, so can't be of much help there. Python is supposedly portable across systems... but to fix a problem, one has to first pinpoint or replicate the exact issue, and that is very difficult if you don't use the same operating system.

author: curtisound
author_rank: Newbie
timestamp: May 28, 2023, 12:17:23 am
content: Thanks for the info! I'm able to easily convert the data from scientific to real numbers easily enough in Excel. Though my software is picky and wants to see all the data in MHz. So 400.000 instead of 400000000.000 . I'm guessing I can make formula to automate this in Excel as well.-Cheers!

author: alm
author_rank: Super Contributor
timestamp: May 30, 2023, 07:13:31 pm
content: A formula could easily do it. Or copy the number 1e6, select the entire column of frequency values, paste special, and choose "divide".

author: curtisound
author_rank: Newbie
timestamp: May 31, 2023, 04:05:01 am
content: Ohh wow thanks! this is actually much easier than the formula I wrote =TEXT(A1/10^6,"0.00#") which I had to copy all the way down an adjacent column with the auto fill function advancing "A1 cell" to A2, A3, A4 etc... to give me a new column with all the frequency values in 1+E6 instead of 1+E8. My software now accepts the new .csv data with problems