Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-server
Commits
eb98d679
Commit
eb98d679
authored
Oct 23, 2020
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
up
parent
cbdbc85a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripting/bin/pandas_table_preview.py
+9
-7
9 additions, 7 deletions
scripting/bin/pandas_table_preview.py
with
9 additions
and
7 deletions
scripting/bin/pandas_table_preview.py
+
9
−
7
View file @
eb98d679
...
@@ -48,8 +48,8 @@ def get_file(eid):
...
@@ -48,8 +48,8 @@ def get_file(eid):
fi
=
db
.
File
(
id
=
eid
)
fi
=
db
.
File
(
id
=
eid
)
fi
.
retrieve
()
fi
.
retrieve
()
except
db
.
exceptions
.
EntityDoesNotExistError
:
except
db
.
exceptions
.
EntityDoesNotExistError
:
return
(
"
Cannot create preview for Entity with ID={}, because it seems
"
print
(
"
Cannot create preview for Entity with ID={}, because it seems
"
"
not to exist.
"
.
format
(
eid
))
"
not to exist.
"
.
format
(
eid
)
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
return
fi
return
fi
...
@@ -76,6 +76,7 @@ def ending_is_valid(fipath):
...
@@ -76,6 +76,7 @@ def ending_is_valid(fipath):
return
get_ending
(
fipath
)
is
not
None
return
get_ending
(
fipath
)
is
not
None
def
read_file
(
fipath
,
ftype
):
def
read_file
(
fipath
,
ftype
):
"""
tries to read the provided file
"""
"""
tries to read the provided file
"""
...
@@ -98,28 +99,29 @@ def read_file(fipath, ftype):
...
@@ -98,28 +99,29 @@ def read_file(fipath, ftype):
def
create_table_preview
(
fi
):
def
create_table_preview
(
fi
):
if
not
ending_is_valid
(
fi
.
path
):
if
not
ending_is_valid
(
fi
.
path
):
print
(
"
Cannot create preview for Entity with ID={}, because download
"
print
(
"
Cannot create preview for Entity with ID={}, because download
"
"
failed.
"
.
format
(
entity_id
))
"
failed.
"
.
format
(
entity_id
)
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
sys
.
exit
(
5
)
ending
=
get_ending
(
fi
.
path
)
ending
=
get_ending
(
fi
.
path
)
if
not
size_is_ok
(
fi
):
if
not
size_is_ok
(
fi
):
print
(
"
Skipped creating a preview for Entity with ID={}, because the
"
print
(
"
Skipped creating a preview for Entity with ID={}, because the
"
"
file is large!
"
.
format
(
entity_id
))
"
file is large!
"
.
format
(
entity_id
)
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
try
:
try
:
tmpfile
=
fi
.
download
()
tmpfile
=
fi
.
download
()
except
Exception
:
except
Exception
:
print
(
"
Cannot create preview for Entity with ID={}, because download
"
print
(
"
Cannot create preview for Entity with ID={}, because download
"
"
failed.
"
.
format
(
entity_id
))
"
failed.
"
.
format
(
entity_id
)
,
file
=
sys
.
stderr
)
sys
.
exit
(
3
)
sys
.
exit
(
3
)
try
:
try
:
df
=
read_file
(
tmpfile
,
ending
)
df
=
read_file
(
tmpfile
,
ending
)
except
ValueError
:
except
ValueError
:
print
(
"
Cannot read File Entity with ID={}.
"
.
format
(
entity_id
))
print
(
"
Cannot read File Entity with ID={}.
"
.
format
(
entity_id
),
file
=
sys
.
stderr
)
sys
.
exit
(
4
)
sys
.
exit
(
4
)
print
(
df
.
to_html
(
max_cols
=
10
,
max_rows
=
10
))
print
(
df
.
to_html
(
max_cols
=
10
,
max_rows
=
10
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment