# Import data

**URL:** <https://discuss.elastic.co/t/import-data/229874>\
**Category:** Elasticsearch\
**Created:** [April 26, 2020, 9:22pm UTC](https://discuss.elastic.co/t/import-data/229874 "2020-04-26T21:22:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![inchirah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inchirah/32/48145_2.png) [@inchirah](https://discuss.elastic.co/u/inchirah)\
**Post date:** [April 26, 2020, 9:22pm UTC](https://discuss.elastic.co/t/import-data/229874/1 "2020-04-26T21:22:16Z")

</div>

Hello,

I build a web app with flask. Through a button the user gonna choose a csv file from a desktop and when he clicks to submit a config file gonna run to import that file (the user previously chosen) into ES. So I got a difficult to code that with flask, this is my try  
1- This is the user interface: profile.html

```auto
{% extends "base.html" %}

{% block content %}
    <h1 class="title"> Welcome, {{ name }}! </h1>
    <h3>You can choose your file </h3>
    <form enctype="multipart/form-data" class="" action="data" method="post">
    	<input type="file" name="csvfile" value="">
    	<input type="submit" name="" value="submit">
    </form>
{% endblock %}

```

2- This is a standard config file: file.config

```auto
input{
	file{
	  
      start_position => "beginning"
      sincedb_path => "NUL"
      codec => plain { charset => "CP1252" }
	}
}
filter{
	csv {
        separator => ";"
        
          
        convert => {
            "longitude" => "float"
            "latitude" => "float"
            
            
        } 
        
    }
    date { match => ["time", "dd MMM yy HH:mm:ss"] }

    mutate{ add_field => { "location" => "%{latitude},%{longitude}" } }
  
}

output{
	elasticsearch { 
	    action => "index"
        hosts => ["http://localhost:9200/"] 
  }
}

```

3- This is the data function : main.py

```auto
from flask import Blueprint, render_template, request
import csv
from flask_login import login_required, current_user
from . import db

main = Blueprint('main', __name__ )

@main.route('/')
def index():
    return render_template('index.html', methods=['GET', 'POST'])

@main.route('/profile')
@login_required
def profile():
    return render_template('profile.html', name=current_user.name) 
    
**@main.route('/data', methods=['GET', 'POST'])**
**def data():**
 **	if request.method == 'POST':**
**f = request.files['csvfile']**
**f.app.config.from_profile('file.config')**

```

Could anyone tell me how I can implement that with flask please.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 29, 2020, 12:48am UTC](https://discuss.elastic.co/t/import-data/229874/2 "2020-04-29T00:48:21Z")

</div>

Please continue the discussion at [Run Logstash config file from a web app](https://discuss.elastic.co/t/run-logstash-config-file-from-a-web-app/230052)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 29, 2020, 12:48am UTC](https://discuss.elastic.co/t/import-data/229874/3 "2020-04-29T00:48:31Z")

</div>


