Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
validata-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
20
Issues
20
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Validata
validata-ui
Commits
bff8385e
Commit
bff8385e
authored
Jun 14, 2019
by
Pierre Dittgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate uploaded CSV file
parent
31d3acd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
5 deletions
+3
-5
validata_ui/validata_util.py
validata_ui/validata_util.py
+2
-4
validata_ui/views.py
validata_ui/views.py
+1
-1
No files found.
validata_ui/validata_util.py
View file @
bff8385e
...
...
@@ -45,10 +45,8 @@ class UploadedFileValidataResource(ValidataResource):
def
build_reader
(
self
):
return
BytesIO
(
self
.
content
)
def
__detect_format
(
self
):
def
__detect_format
_from_file_extension
(
self
):
ext
=
Path
(
self
.
filename
).
suffix
import
ipdb
ipdb
.
set_trace
()
if
ext
in
(
'.csv'
,
'.tsv'
,
'.ods'
,
'.xls'
,
'.xlsx'
):
return
ext
[
1
:]
return
None
...
...
@@ -57,6 +55,6 @@ class UploadedFileValidataResource(ValidataResource):
"""Uploaded file implementation"""
options
=
{
'scheme'
:
'stream'
,
# 'format': self.__detect_format
()
'format'
:
self
.
__detect_format_from_file_extension
()
}
return
(
self
.
build_reader
(),
options
)
validata_ui/views.py
View file @
bff8385e
...
...
@@ -101,7 +101,7 @@ def extract_source_data(source: ValidataResource, preview_rows_nb=5):
# options['delimiter'] = csv_helpers.detect_dialect(source.source, format=source.format, scheme=source.scheme,
# custom_loaders=custom_loaders).delimiter
tabulator_source
,
tabulator_options
=
source
.
build_tabulator_stream_args
()
with
tabulator
.
Stream
(
tabulator_source
,
tabulator_options
)
as
stream
:
with
tabulator
.
Stream
(
tabulator_source
,
**
tabulator_options
)
as
stream
:
for
row
in
stream
:
if
header
is
None
:
header
=
[
''
if
v
is
None
else
v
for
v
in
row
]
...
...
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