Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kodex
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
kodex
Commits
14a92bc6
Commit
14a92bc6
authored
Jan 31, 2018
by
Yannick Chudy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
raise csv error with empty file
parent
4e155c2b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
botapad.py
botapad.py
+4
-4
botapadapp.py
botapadapp.py
+2
-1
botapadapp.html
templates/botapadapp.html
+1
-0
No files found.
botapad.py
View file @
14a92bc6
...
@@ -222,9 +222,12 @@ class Botapad(object):
...
@@ -222,9 +222,12 @@ class Botapad(object):
lines
=
[
line
.
strip
()
for
line
in
lines
]
lines
=
[
line
.
strip
()
for
line
in
lines
]
lines
=
[
line
.
encode
(
'utf8'
)
for
line
in
lines
if
len
(
line
)]
lines
=
[
line
.
encode
(
'utf8'
)
for
line
in
lines
if
len
(
line
)]
if
not
len
(
lines
):
raise
BotapadCsvError
(
path
,
separator
,
"Table is empty
%
s lines"
%
(
len
(
lines
)
)
)
if
separator
==
'auto'
:
if
separator
==
'auto'
:
line
=
lines
[
0
]
.
strip
()
line
=
lines
[
0
]
.
strip
()
print
'auto'
,
lines
[
0
]
.
strip
(),
line
[
1
:]
==
"!;"
if
line
in
(
'!;'
,
'!,'
):
if
line
in
(
'!;'
,
'!,'
):
separator
=
line
[
1
:]
separator
=
line
[
1
:]
else
:
separator
=
','
else
:
separator
=
','
...
@@ -234,8 +237,6 @@ class Botapad(object):
...
@@ -234,8 +237,6 @@ class Botapad(object):
try
:
try
:
reader
=
csv
.
reader
(
lines
,
delimiter
=
separator
)
reader
=
csv
.
reader
(
lines
,
delimiter
=
separator
)
rows
=
[
r
for
r
in
reader
]
rows
=
[
r
for
r
in
reader
]
#start_col = 0 if start_col is None else start_col
#rows = [ r[start_col:end_col] for r in rows]
rows
=
[
[
e
.
strip
()
.
decode
(
'utf8'
)
for
e
in
r
]
for
r
in
rows
if
len
(
r
)
and
not
all
([
len
(
e
)
==
0
for
e
in
r
])
]
rows
=
[
[
e
.
strip
()
.
decode
(
'utf8'
)
for
e
in
r
]
for
r
in
rows
if
len
(
r
)
and
not
all
([
len
(
e
)
==
0
for
e
in
r
])
]
except
:
except
:
raise
BotapadCsvError
(
path
,
separator
,
"Error while parsing data
%
s lines with separator
%
s"
%
(
len
(
lines
),
separator
)
)
raise
BotapadCsvError
(
path
,
separator
,
"Error while parsing data
%
s lines with separator
%
s"
%
(
len
(
lines
),
separator
)
)
...
@@ -264,7 +265,6 @@ class Botapad(object):
...
@@ -264,7 +265,6 @@ class Botapad(object):
def
_parse
(
self
,
path
,
rows
,
**
kwargs
):
def
_parse
(
self
,
path
,
rows
,
**
kwargs
):
""" :param path : txt file path
""" :param path : txt file path
handles special lines starting with [# @ _]
for comments, node type, property names
for comments, node type, property names
"""
"""
...
...
botapadapp.py
View file @
14a92bc6
...
@@ -489,6 +489,7 @@ def botimport(repo, padurl, gid, content_type):
...
@@ -489,6 +489,7 @@ def botimport(repo, padurl, gid, content_type):
'class'
:
err
.
__class__
.
__name__
,
'class'
:
err
.
__class__
.
__name__
,
'url'
:
err
.
path
,
'url'
:
err
.
path
,
'separator'
:
err
.
separator
,
'separator'
:
err
.
separator
,
'message'
:
err
.
message
}
}
except
BotapadParseError
as
err
:
except
BotapadParseError
as
err
:
...
...
templates/botapadapp.html
View file @
14a92bc6
...
@@ -352,6 +352,7 @@
...
@@ -352,6 +352,7 @@
<ul
class=
"list"
>
<ul
class=
"list"
>
<li>
Error while parsing
<a
href=
"{{error.url}}"
target=
"_blank"
>
{{error.url}}
</a></li>
<li>
Error while parsing
<a
href=
"{{error.url}}"
target=
"_blank"
>
{{error.url}}
</a></li>
<li>
Parsing data failed in {{error.url}}
</li>
<li>
Parsing data failed in {{error.url}}
</li>
<li>
{{error.message}}
</li>
<li>
we used the character
<code>
{{error.separator}}
</code>
as a separator
</li>
<li>
we used the character
<code>
{{error.separator}}
</code>
as a separator
</li>
</ul>
{% elif error.class == "BotapadParseError" %}
</ul>
{% elif error.class == "BotapadParseError" %}
<ul
class=
"list"
>
<ul
class=
"list"
>
...
...
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