![]() |
|
[Tut] How to Read and Convert a Binary File to CSV in Python? - Printable Version +- Sick Gaming (https://sickgaming.net) +-- Forum: Programming (https://sickgaming.net/forum-76.html) +--- Forum: Python (https://sickgaming.net/forum-83.html) +--- Thread: [Tut] How to Read and Convert a Binary File to CSV in Python? (/thread-99785.html) |
[Tut] How to Read and Convert a Binary File to CSV in Python? - xSicKxBot - 08-09-2022 How to Read and Convert a Binary File to CSV in Python? 5/5 – (1 vote) To read a binary file, use the Code: open('rb')Code: withCode: f.readlines()Code: csvHere’s an example to read the binary file Code: 'my_file.man'Code: with open('my_file.man', 'rb') as f: content = f.readlines() print(content)Per default, Python’s built-in Code: open()Code: 'b'Code: mode
Now that the content is in your Python script, you can convert it to a CSV using the various methods outlined in this article: Learn More: Convert a String to CSV in PythonAfter you’ve converted the data to the comma-separated values (CSV) format demanded by your application, you can write the string to a file using either the Code: print()Code: file.write() |