Mastering Development

import multiple excel files to pandas and export to multiple stata files

  1. my raw excels files are[excel_1,excel_2,…,excel_3], at first I want to import them into dataframes and then append them into a big dataframe, then df.to_dta, but python shows error and said: Memoryerror. I guess the problem is the appended dataframe is too big.

  2. so I thought I could transform each excel files to each stata file and append them in stata, but I dont know how to do that.

  3. my original code is as follow:

    import pandas as pd
    IO = ‘excel_1.xlsx’

df = pd.read_excel(io=IO, skiprows = [1,2] ,
dtype={"Opnprc": "str","Hiprc": "str","Loprc": "str","Clsprc": "str","Dnshrtrd": "str","Dnvaltrd": "str","Dsmvosd": "str",
"Dsmvtll": "str","Dretwd": "str","Dretnd": "str","Adjprcwd": "str","Adjprcnd": "str","Markettype": "str",
"Trdsta": "str"})

I guess a for loop should work, but I dont know how to do that.

Leave a Reply

Your email address will not be published. Required fields are marked *