0

I have many csv files in S3 and i want to read only 7 columns from each files through pandas. But in the output csv files for numerical column I am getting decimal values as well.like for count 9.0,6.0 but i want to read everything as a text only. like 9 and 6. I tried from pd.read_fwf but still issue is not resolved. can someone help me out please.

cols=["name","Phone","cost","count","location","location1", "family_count"]

reader = pd.read_csv(io.BytesIO(body), delimiter=',', quotechar='"',
                         encoding='utf8', quoting=csv.QUOTE_ALL, skipinitialspace=True, 
                          usecols=cols)
reader.reset_index()

csv_buffer = BytesIO()

reader.to_csv(csv_buffer, index=False)

I tried to specify dtype=object

reader = pd.read_csv(io.BytesIO(body), delimiter=',', quotechar='"',
                     encoding='utf8', quoting=csv.QUOTE_ALL, skipinitialspace=True, 
                      usecols=cols,dtype=object)

but then i an getting type error:"Data type not understood"

0 Answers0