0

I have csv file data. and I want to convert that csv file data either directly to excel file(.xls or .xlsx) or by reading csv file data and write to excel file. at the end format should be in correct...means number types should be in number,date should be in date format.

I have used below code to do the above task. but the numbers are coming as string only.

import pandas as pd
import numpy as np

msft = pd.read_csv("input.csv")

df = msft.head(n=3000)
df.to_excel("output.xls", index=None, header=None)
name    rollno  marks   doj   
xxx      100      99    15-Jul-16  
yyy      200      90    10-Feb-17

Sample Data

Can anyone please help on this.

Thanks in advance...

MegaIng
  • 7,361
  • 1
  • 22
  • 35
  • 1
    Why convert? Why not just open the CSV with Excel? CSV was practically *made* for Excel. **What are you hoping *gain*** by converting? – ashleedawg May 16 '18 at 16:51
  • Currently I am getting multiple reports in csv file format, but I have a formatted and prepared excel report which is presenting to the management. in the excel they have mapped multiple reports which are in .xls format. Currently we are manually converting the received csv file report to excel files and generating the formated report. – Aneel kumar May 16 '18 at 17:36

0 Answers0