Home > Back-end >  How to get a csv file from a folder?
How to get a csv file from a folder?

Time:04-17

So my folder structure looks like this

MP_Data
|___dir1
|   | 0
|     |___ 0.npy
|     |___ 1.npy
|     .
|     .
|     29
|   | 1
|     |___ 0.npy
|     |___ 1.npy
|     .
|     .
|     29
|   .
|   .
|   29
|___dir2
|   | 0
|     |___ 0.npy
|     |___ 1.npy
|     .
|     .
|     29
|   | 1
|     |___ 0.npy
|     |___ 1.npy
|     .
|     .
|     29
|   .
|   .
|   29
|___dir3
|   | 0
|     |___ 0.npy
|     |___ 1.npy
|     .
|     .
|     29
|   | 1
|     |___ 0.npy
|     |___ 1.npy
|     .
|     .
|     29
|   .
|   .
|   29

So I need csv file for including dataset for creating model for deploying it using flask. I am super new to flask so I've no clue how to do this, can anyone pls help me?

CodePudding user response:

Quite simple.

Use the following approach (relative to where you've saved your python file).

I'll be assuming you've saved your python file in MP_Data and that your CSV file is in dir1.

import pandas as pd

df = pd.read_csv('dir1/data.csv')

print(df)

CodePudding user response:

I am using this approach!

import pandas as pd

#loading the data
data = pd.read_csv('file:///C:/Users/d/Downloads/Nifty_50_Futures_Historical_Data.csv')

print(data)

  • Related