Austin Jiang
Austin Jiang

Reputation: 31

Solve empty file issue in Colab

I try download a file in Google Colab

  train_url = "https://drive.google.com/file/d/1tBjLm79vkDqn8GulvvKb6FLH5ghmBpMq/view?usp=sharing"
  !wget -O train.csv -b train_url &
  train = pd.read_csv(r"./train.csv",dtype = np.float32)

Two Questions:

  1. After download this file, however the file always shows as 0 byte, which means it's a empty file. Not sure why
  2. I want waiting the file is downloaded, then the pd can start to read the csv file. Related Solution

Upvotes: 0

Views: 635

Answers (1)

Shijith
Shijith

Reputation: 4872

you can read the file directly using pandas

train_url = "https://drive.google.com/file/d/1tBjLm79vkDqn8GulvvKb6FLH5ghmBpMq/view?usp=sharing"
load_url = f'https://drive.google.com/uc?export=download&id={train_url.split('/')[-2]}'
train = pd.read_csv(load_url,dtype = np.float32)
>>>print(train.head())
   label  pixel0  pixel1  pixel2  ...  pixel780  pixel781  pixel782  pixel783
0      1       0       0       0  ...         0         0         0         0
1      0       0       0       0  ...         0         0         0         0
2      1       0       0       0  ...         0         0         0         0
3      4       0       0       0  ...         0         0         0         0
4      0       0       0       0  ...         0         0         0         0

Upvotes: 1

Related Questions