Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
jvenn
Commits
767aad13
Commit
767aad13
authored
Feb 23, 2017
by
Philippe Bardou
Browse files
Upload list : Test the input file
- Each line must have the same number of field - File must be text...
parent
dce818c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/jvenn_server.py
View file @
767aad13
...
...
@@ -38,7 +38,10 @@ class AppServer(object):
delimiter
=
'
\t
'
if
(
kwargs
[
"delimiter"
]
==
","
or
kwargs
[
"delimiter"
]
==
";"
)
:
delimiter
=
kwargs
[
"delimiter"
]
file_path
=
self
.
__upload
(
**
kwargs
)
try
:
file_path
=
self
.
__upload
(
**
kwargs
)
except
:
return
json
.
dumps
([{
'error'
:
"Error: Please provide a delimited text file."
}])
return
self
.
__compare_lists
(
file_path
,
kwargs
[
"header"
],
delimiter
)
def
__upload
(
self
,
**
kwargs
):
...
...
@@ -67,11 +70,15 @@ class AppServer(object):
FH
=
open
(
file
,
'r'
)
names
=
{}
samples
=
{}
linenb
=
0
for
i
,
line
in
enumerate
(
FH
.
readlines
()):
if
i
==
0
:
linenb
=
len
(
line
.
split
(
spliter
))
if
i
==
0
and
header
:
for
j
,
val
in
enumerate
(
line
.
split
(
spliter
)):
names
[
string
.
ascii_uppercase
[
j
]]
=
val
.
rstrip
(
'
\n\r
'
)
linenb
=
len
(
names
)
else
:
for
j
,
val
in
enumerate
(
line
.
split
(
spliter
)):
if
i
==
0
:
...
...
@@ -80,7 +87,10 @@ class AppServer(object):
samples
[
j
].
append
(
val
)
else
:
samples
[
j
]
=
[
val
]
if
linenb
!=
len
(
line
.
split
(
spliter
)):
return
json
.
dumps
([{
'error'
:
"Error: Inconsistent number of fields line "
+
str
(
i
+
1
)
+
" ("
+
str
(
len
(
line
.
split
(
spliter
)))
+
" for "
+
str
(
linenb
)
+
" expected)"
}])
d
=
{}
j
=
1
...
...
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