pythongnuradio

Export signal generated from GNU Radio Companion to a .csv file


I am trying to generate a random signal using GNU Radio Companion and then export it to a .csv file. I have used a signal source to generate a signal. Then I have connected it to the throttle box. The output has then been connected to the "file sink" block to save the signal into a .csv file. From my understanding the sink block is used to export the data to a file, which in this case is an excel file. However, when I open the .csv file the output is shown in weird characters rather than a number. What is the reason behind this?


Solution

  • From my understanding the sink block is used to export the data to a file, which in this case is an excel file.

    Your understanding is wrong, sadly! The file extension says literally nothing about the contents and format of a file.

    What the file sink writes is simply the values you put in, byte for byte, as they would appear in RAM. That's rather well-documented on the official wiki page of the File Sink block.

    What is the reason behind this?

    Simple: it's not a text file as you expect it to be (CSV is not an Excel file, but "comma separated values in a text file").

    Export signal generated from GNU Radio Companion to a .csv file

    GNU Radio does not come with a block that writes values comma-separatedly. And that's not really by accident: CSV is among the least suitable formats for numerical data, especially complex data. Beyond a couple thousand values, it gets hard to manage data in a text editor or with tools like excel, and typical GNU Radio applications produce millions of values per second! Not to mention that writing a CSV is highly space-inefficient and takes a lot of CPU power, since the nice numerical values that are in a precision-preserving format (for example, 16bit integers, or 32 bit floats interleaving I and Q) have to be "rendered" to a textual representation – which can be both a lossy process and takes litte data and makes much data out of it.

    So, in short, maybe don't do CSV.