I have used this code to parse csv using python flask
from flask import Flask, make_response, request, render_template
import csv
app = Flask(__name__)
def transform(text_file_contents):
#return text_file_contents.replace("=", ",")
return text_file_contents
@app.route('/')
def form():
return """ Transform a file demo
<form action="/transform" method="post" enctype="multipart/form-data">
<input type="file" name="data_file" />
<input type="submit" />
<form>"""
@app.route('/transform', methods=["POST"])
def transform_view():
file = request.files['data_file']
if not file:
return "No file"
file_contents = file.stream.read().decode("utf-8")
csv_input = csv.reader(file_contents)
result = transform(file_contents)
print result
return result
return render_template('commission.sh', result=result)
if __name__ == "__main__":
import webbrowser
webbrowser.open('localhost:5000')
app.run()
The above is to parse the csv and display the output. But I need to send the output to the shell script as input to proceed further in the shell script itself.. Thanks in advance...