Converting raw file content from Flask file upload into dataframe using pandas

前端 未结 1 650
日久生厌
日久生厌 2021-01-01 01:40

I am trying to upload a csv file to my flask server. What I want to do is to read its content into a dataframe without saving it on the file system

相关标签:
1条回答
  • 2021-01-01 02:00

    pandas.read_csv() can take any file-like object (with a read() method) as input, so just use it: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html#pandas.read_csv

    @app.route('/upload', methods=['POST'])
    def upload():
        df = pandas.read_csv(request.files.get('uploaded_file'))
    
    0 讨论(0)
提交回复
热议问题