Table with html and javascript from a csv file
The table has about 10,000 rows. When the page loads it takes a long time.
I want to add sort and filter and pagination function to it.How can I do so ?
I want some knowledge about how to use datatables with Javascript and Ajax.
javascript html csv html-table
add a comment |
The table has about 10,000 rows. When the page loads it takes a long time.
I want to add sort and filter and pagination function to it.How can I do so ?
I want some knowledge about how to use datatables with Javascript and Ajax.
javascript html csv html-table
3
Have a look at datatables.net and search google for some examples. Unfortunately, this is a bit too broad of a question for SO, as it involves a lot of different pieces, and several ways of doing this.
– FrankerZ
Nov 23 '18 at 5:30
Yep, check out datatables.net/manual/data and ask a specific question about your issue when you get stuck.
– JasonB
Nov 23 '18 at 6:23
add a comment |
The table has about 10,000 rows. When the page loads it takes a long time.
I want to add sort and filter and pagination function to it.How can I do so ?
I want some knowledge about how to use datatables with Javascript and Ajax.
javascript html csv html-table
The table has about 10,000 rows. When the page loads it takes a long time.
I want to add sort and filter and pagination function to it.How can I do so ?
I want some knowledge about how to use datatables with Javascript and Ajax.
javascript html csv html-table
javascript html csv html-table
edited Nov 23 '18 at 9:55
piet.t
10.1k73246
10.1k73246
asked Nov 23 '18 at 5:27
Sahil 123Sahil 123
36
36
3
Have a look at datatables.net and search google for some examples. Unfortunately, this is a bit too broad of a question for SO, as it involves a lot of different pieces, and several ways of doing this.
– FrankerZ
Nov 23 '18 at 5:30
Yep, check out datatables.net/manual/data and ask a specific question about your issue when you get stuck.
– JasonB
Nov 23 '18 at 6:23
add a comment |
3
Have a look at datatables.net and search google for some examples. Unfortunately, this is a bit too broad of a question for SO, as it involves a lot of different pieces, and several ways of doing this.
– FrankerZ
Nov 23 '18 at 5:30
Yep, check out datatables.net/manual/data and ask a specific question about your issue when you get stuck.
– JasonB
Nov 23 '18 at 6:23
3
3
Have a look at datatables.net and search google for some examples. Unfortunately, this is a bit too broad of a question for SO, as it involves a lot of different pieces, and several ways of doing this.
– FrankerZ
Nov 23 '18 at 5:30
Have a look at datatables.net and search google for some examples. Unfortunately, this is a bit too broad of a question for SO, as it involves a lot of different pieces, and several ways of doing this.
– FrankerZ
Nov 23 '18 at 5:30
Yep, check out datatables.net/manual/data and ask a specific question about your issue when you get stuck.
– JasonB
Nov 23 '18 at 6:23
Yep, check out datatables.net/manual/data and ask a specific question about your issue when you get stuck.
– JasonB
Nov 23 '18 at 6:23
add a comment |
1 Answer
1
active
oldest
votes
This solution is something you can consider. It requires some knowledge of Python particularly Pandas ( a python Library) and Flask( microframework).
Use this snippet to read csv and convert to html tables.
Python code
@app.route("/")
def show_tables():
data = pd.read_csv("myfile.csv")
return render_template('index.html',tables=[re.sub(' mytable', '" id="example', data.to_html(classes='mytable'))],
titles = ['Excel Data to Flask'])
index.html
<!doctype html>
<head>
<link rel=stylesheet type=text/css href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel=stylesheet type=text/css href="https://cdn.datatables.net/plug-ins/f2c75b7247b/integration/bootstrap/3/dataTables.bootstrap.css">
<!--<link rel=stylesheet type=text/css href="https://cdn.datatables.net/responsive/1.0.4/css/dataTables.responsive.css"> -->
</head>
<body>
<div class=page>
{% for table in tables %}
<h2>{{titles[loop.index]}}</h2>
{{ table|safe }}
{% endfor %}
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"> </script>
</body>
</html>
You can read more about the topic here Pandas : CSV to HTML
This will make reading csv files easier and faster along with the use of javascript datables.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441055%2ftable-with-html-and-javascript-from-a-csv-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This solution is something you can consider. It requires some knowledge of Python particularly Pandas ( a python Library) and Flask( microframework).
Use this snippet to read csv and convert to html tables.
Python code
@app.route("/")
def show_tables():
data = pd.read_csv("myfile.csv")
return render_template('index.html',tables=[re.sub(' mytable', '" id="example', data.to_html(classes='mytable'))],
titles = ['Excel Data to Flask'])
index.html
<!doctype html>
<head>
<link rel=stylesheet type=text/css href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel=stylesheet type=text/css href="https://cdn.datatables.net/plug-ins/f2c75b7247b/integration/bootstrap/3/dataTables.bootstrap.css">
<!--<link rel=stylesheet type=text/css href="https://cdn.datatables.net/responsive/1.0.4/css/dataTables.responsive.css"> -->
</head>
<body>
<div class=page>
{% for table in tables %}
<h2>{{titles[loop.index]}}</h2>
{{ table|safe }}
{% endfor %}
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"> </script>
</body>
</html>
You can read more about the topic here Pandas : CSV to HTML
This will make reading csv files easier and faster along with the use of javascript datables.
add a comment |
This solution is something you can consider. It requires some knowledge of Python particularly Pandas ( a python Library) and Flask( microframework).
Use this snippet to read csv and convert to html tables.
Python code
@app.route("/")
def show_tables():
data = pd.read_csv("myfile.csv")
return render_template('index.html',tables=[re.sub(' mytable', '" id="example', data.to_html(classes='mytable'))],
titles = ['Excel Data to Flask'])
index.html
<!doctype html>
<head>
<link rel=stylesheet type=text/css href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel=stylesheet type=text/css href="https://cdn.datatables.net/plug-ins/f2c75b7247b/integration/bootstrap/3/dataTables.bootstrap.css">
<!--<link rel=stylesheet type=text/css href="https://cdn.datatables.net/responsive/1.0.4/css/dataTables.responsive.css"> -->
</head>
<body>
<div class=page>
{% for table in tables %}
<h2>{{titles[loop.index]}}</h2>
{{ table|safe }}
{% endfor %}
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"> </script>
</body>
</html>
You can read more about the topic here Pandas : CSV to HTML
This will make reading csv files easier and faster along with the use of javascript datables.
add a comment |
This solution is something you can consider. It requires some knowledge of Python particularly Pandas ( a python Library) and Flask( microframework).
Use this snippet to read csv and convert to html tables.
Python code
@app.route("/")
def show_tables():
data = pd.read_csv("myfile.csv")
return render_template('index.html',tables=[re.sub(' mytable', '" id="example', data.to_html(classes='mytable'))],
titles = ['Excel Data to Flask'])
index.html
<!doctype html>
<head>
<link rel=stylesheet type=text/css href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel=stylesheet type=text/css href="https://cdn.datatables.net/plug-ins/f2c75b7247b/integration/bootstrap/3/dataTables.bootstrap.css">
<!--<link rel=stylesheet type=text/css href="https://cdn.datatables.net/responsive/1.0.4/css/dataTables.responsive.css"> -->
</head>
<body>
<div class=page>
{% for table in tables %}
<h2>{{titles[loop.index]}}</h2>
{{ table|safe }}
{% endfor %}
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"> </script>
</body>
</html>
You can read more about the topic here Pandas : CSV to HTML
This will make reading csv files easier and faster along with the use of javascript datables.
This solution is something you can consider. It requires some knowledge of Python particularly Pandas ( a python Library) and Flask( microframework).
Use this snippet to read csv and convert to html tables.
Python code
@app.route("/")
def show_tables():
data = pd.read_csv("myfile.csv")
return render_template('index.html',tables=[re.sub(' mytable', '" id="example', data.to_html(classes='mytable'))],
titles = ['Excel Data to Flask'])
index.html
<!doctype html>
<head>
<link rel=stylesheet type=text/css href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel=stylesheet type=text/css href="https://cdn.datatables.net/plug-ins/f2c75b7247b/integration/bootstrap/3/dataTables.bootstrap.css">
<!--<link rel=stylesheet type=text/css href="https://cdn.datatables.net/responsive/1.0.4/css/dataTables.responsive.css"> -->
</head>
<body>
<div class=page>
{% for table in tables %}
<h2>{{titles[loop.index]}}</h2>
{{ table|safe }}
{% endfor %}
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"> </script>
</body>
</html>
You can read more about the topic here Pandas : CSV to HTML
This will make reading csv files easier and faster along with the use of javascript datables.
answered Nov 23 '18 at 6:41
Duck_dragonDuck_dragon
768
768
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441055%2ftable-with-html-and-javascript-from-a-csv-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Have a look at datatables.net and search google for some examples. Unfortunately, this is a bit too broad of a question for SO, as it involves a lot of different pieces, and several ways of doing this.
– FrankerZ
Nov 23 '18 at 5:30
Yep, check out datatables.net/manual/data and ask a specific question about your issue when you get stuck.
– JasonB
Nov 23 '18 at 6:23