Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
e5ceb486
Commit
e5ceb486
authored
Nov 07, 2014
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEATURE] CHART export CSV: ok
parent
fc6c91c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
15 deletions
+9
-15
views.py
gargantext_web/views.py
+8
-15
corpus.html
templates/corpus.html
+1
-0
No files found.
gargantext_web/views.py
View file @
e5ceb486
...
...
@@ -415,7 +415,6 @@ def explorer_chart(request):
import
csv
from
django.db
import
connection
cursor
=
connection
.
cursor
()
def
send_csv
(
request
):
'''
...
...
@@ -425,18 +424,14 @@ def send_csv(request):
response
[
'Content-Disposition'
]
=
'attachment; filename="data.csv"'
writer
=
csv
.
writer
(
response
)
# file = open('/srv/gargantext/static/js/d3/ndx.csv', 'r')
# for line in file.readlines():
# writer.writerow(line)
# writer.writerow(['date','open','high','low','close','volume','oi'])
# writer.writerow(['12/19/2001','96.05','99.98','95.79','99.98','1260','0'])
#writer = csv.writer(response, delimiter=',', quotechar=' ', quoting=csv.QUOTE_NONE)
cursor
=
connection
.
cursor
()
cursor
.
execute
(
"""
SELECT
metadata -> 'publication_year' as year,
metadata -> 'publication_month' as month,
metadata -> 'publication_month' as month,
metadata -> 'publication_day' as day,
COUNT(*)
FROM
...
...
@@ -447,9 +442,7 @@ def send_csv(request):
day, month, year
ORDER BY
year, month, day ASC
LIMIT
20
"""
,
[
5102
])
"""
,
[
5013
])
writer
.
writerow
([
'date'
,
'data'
])
...
...
@@ -457,11 +450,11 @@ def send_csv(request):
row
=
cursor
.
fetchone
()
if
row
is
None
:
break
writer
.
writerow
([
row
[
0
]
+
'/'
+
row
[
1
]
+
'/'
+
row
[
2
]
+
','
+
str
(
row
[
3
])
])
writer
.
writerow
([
row
[
0
]
+
'/'
+
row
[
1
]
+
'/'
+
row
[
2
]
,
str
(
row
[
3
])
])
return
response
cursor
.
close
()
return
response
def
send_graph
(
request
):
'''
...
...
templates/corpus.html
View file @
e5ceb486
...
...
@@ -65,6 +65,7 @@
</div>
</div>
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/data.csv"
>
Save
</a></p>
<div
class=
"container"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment