How to Generate a csv file in python 3.7 - python-3.x

I have a problem where I have to fetch the data through API calls using Python. I have the data. Now I have to convert it to a csv file.
We do not have to use numpy or panda. We can only use "Import collections" to generate csv file.
I am a beginner in python. Can someone help me with that please?

Related

Python - read EBCIDIC encoded .dat file into a pandas df

I have a .dat file exported from a mainframe system. It is EBCIDIC encoded(cp037). I would like to load the contents into a pandas or spark dataframe.
I tried using "iconv" to convert the file to ascii, it does not support conversion from cp037. "iconv -l" does not list cp037.
What is the best way to achieve this?

Save table as image or csv file when using tabulate library in python

I want to save such a table as an image or CSV file. I used the tabulate library to produce the table. I know I can create it from pandas, but I need to make it by this library. Can anyone guide me? Thanks
from tabulate import tabulate
print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
The output is:

Write output in xlsb file format (Excel binary file format) using pandas and pyxlsb

I've read a lot of stackoverflow and other threads where it's been mentioned how to read excel binary file.
Reference: Read XLSB File in Pandas Python
import pandas as pd
df = pd.read_excel('path_to_file.xlsb', engine='pyxlsb')
However, I can not find any solution on how to write it back as .xlsb file after processing using pandas? Can anyone please suggest a workable solution for this using python?
Any help is much appreciated!
I haven't been able to find any solution to write into xlsb files or create xlsb files using python.
But maybe one work around is to save your file as xlsx using any of the many available libraries to do that (such as pandas, xlsxwriter, openpyxl) and then converting that file into a xlsb using xlsb-converter. https://github.com/gibz104/xlsb-converter
CAUTION: This repository uses WIN32COM, which is why this script only supports Windows
you can read binary file with open_workbook under pyxlsb. Please find below the code:
import pandas as pd
from pyxlsb import open_workbook
path=r'D:\path_to_file.xlsb'
df2=[]
with open_workbook(path) as wb:
with wb.get_sheet(1) as sheet:
for row in sheet.rows():
df2.append([item.v for item in row])
data= pd.DataFrame(df2[1:], columns=df2[0])

THREDDS & METAR Plotting with Python

I'm having trouble trying to plot METAR data from the THREDDS data server, which comes in .nc format, onto a map. I'm using Siphon to grab the data and Xarray to open the dataset with remote_access, but the problem comes with attempting to convert the data to .csv or .txt. When using NetCDF Dataset and attempting to read the NetCDF4 file, I get a file does not exist error. I'm not really sure where to start as there doesn't seem to be much on the internet about this. Any help would be appreciated as I'm also really new to this.

import python pickle files into mongodb

I have some pickle files, and I want to load them into Mongodb, without converting them into other formats like csv and JSON. Please let me know if there is a way to do this.
collection.insert({'yourkey': Binary(yourPickleFiles))})

Resources