Home > Enterprise >  OSError: [Errno 36] File name too long: for python package and .txt file, pandas opening
OSError: [Errno 36] File name too long: for python package and .txt file, pandas opening

Time:09-23

Error OSError: [Errno 36] File name too long: for the following code:

from importlib_resources import open_text
import pandas as pd

with open_text('package.data', 'librebook.txt') as f:
    input_file = f.read()

dataset = pd.read_csv(input_file)

Ubuntu 20.04 OS, this is for a python package, init.py file

I dont want to use .readlines()

Can I structure this code differently to not have this outcome occur? Do I need to modify my OS system? Some of the help I found looked to modify OS but dont want to do this if I dont need to. Thank you.

CodePudding user response:

why not just pass in the name of the file and not the contents

dataset = pd.read_csv('librebook.txt')

CodePudding user response:

from importlib_resources import path import pandas as pd

with path('package.data', 'librebook.txt') as f: dataset = pd.read_csv(f)

  • Related