Python Forum
pandas.read_sas with chunksize: IndexError list index out of range
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pandas.read_sas with chunksize: IndexError list index out of range
Good morning,

I have read the rules about posting but i cannot attach a sample of my data or reproduce the entire error message as the data i am working on is located on a server without access to internet. I apologise for this inconvenience. I'll try to reproduce most of what is requested however below.

I am working with very big sas files (data on each job, hence millions of lines) and got memory error when i was trying to simple read them (they open fine in R or stata strangely). Therefore i searched and find the pandas.read_sas option to work with chunks of the data. My code is now the following:

df_chunk = pd.read_sas(r'file.sas7bdat', chunksize=500)

for chunk in df_chunk:  

At this point i get the following error (I am reproducing it here manually as i cannot copy paste):

line 660, in _chunk_to_dataframe if self.column_formats[j] in const.sas_date_formats: IndexError: list index out of range
Looking deeper in the error message, the issue seems to be in the underlying function "
" in the following line :
if self.column_formats[j] in const.sas_date_formats 
Many thanks for your help,

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Getting Index Error - list index out of range krishna 2 146 Jan-09-2021, 08:29 AM
Last Post: buran
  Comparing results within a list and appending to pandas dataframe Aryagm 1 189 Dec-17-2020, 01:08 PM
Last Post: palladium
  Cycle through Numpy range within another range(?) Zero01 0 449 Jul-31-2020, 02:37 PM
Last Post: Zero01
  [pandas] How to reshape the list Mekala 6 673 Jul-26-2020, 12:49 AM
Last Post: Mekala
  IndexError: index 0 is out of bounds for axis 0 with size 0 tmhsa 0 1,000 Apr-24-2020, 10:00 AM
Last Post: tmhsa
  Getting Index Error - list index out of range RahulSingh 2 1,609 Feb-03-2020, 07:17 AM
Last Post: RahulSingh
  itertuples, datetime, pandas, groupby, in range karlito 0 934 Nov-29-2019, 11:35 AM
Last Post: karlito
  iterate over index and define each range as a day karlito 7 945 Nov-19-2019, 06:37 AM
Last Post: karlito
  How to speed up work with pandas index? AlekseyPython 1 590 Oct-16-2019, 02:06 PM
Last Post: AlekseyPython
  IndexError: index out of bounds LeoGER 3 4,612 Sep-05-2019, 02:05 PM
Last Post: LeoGER

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020