Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-csv-import
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-csv-import
Commits
c0d2a4ef
Commit
c0d2a4ef
authored
Feb 22, 2013
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Working on Risk import
parent
3fd42c59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
3 deletions
+57
-3
intranet-csv-import-procs.tcl
tcl/intranet-csv-import-procs.tcl
+41
-0
import-2.tcl
www/import-2.tcl
+5
-0
import-im_risk.tcl
www/import-im_risk.tcl
+11
-3
No files found.
tcl/intranet-csv-import-procs.tcl
View file @
c0d2a4ef
...
...
@@ -548,4 +548,45 @@ ad_proc -public im_csv_import_convert_project_parent_nrs {
}
return
[
im_csv_import_convert_project_parent_nrs -parent_id
$parent
_id
$parent
_nrs
]
}
# ---------------------------------------------------------------------
#
# ---------------------------------------------------------------------
ad_proc -public im_csv_import_check_list_of_lists
{
lol
}
{
Check that the parameter is a list of lists with all
line having the same length.
Returns a HTML string of LI error messages or an emtpy
string if there was no issue.
}
{
set length_list
[
list
]
set min_length 1000
set max_length 0
set result
""
foreach line
$lol
{
set length
[
llength
$line
]
if
{
$length
>
$max
_length
}
{
set max_length
$length
}
if
{
$length
<
$min
_length
}
{
set min_length
$length
}
lappend length_list
$length
}
set ctr 0
foreach line
$lol
{
set length
[
llength
$line
]
if
{
$length
< 4
}
{
append result
"<li>Line #
$ctr:
Found a (nearly) empty line with only
$length
columns.
\n
"
}
if
{
$length
<
$max
_length
}
{
# append result
"<li>Line #
$ctr:
Found a line with
$length
elements which doesn't match the
$max
_length width.
\n
"
}
incr ctr
}
return
$result
}
\ No newline at end of file
www/import-2.tcl
View file @
c0d2a4ef
...
...
@@ -97,6 +97,11 @@ set headers [im_csv_split $header $separator]
set
header_len
[
llength
$headers
]
set
values_lol
[
im_csv_get_values
$lines
_content
$separator
]
# Check if there are lines with less then 4 elements
# set error [im_csv_import_check_list_of_lists $values_lol
]
# if {"" != $error
}
{
ad_return_complaint 1
$error
}
# Take a sample of max_row rows from the file and show
set
max_row 10
for
{
set
i 1
}
{
$i
<=
$max
_row
}
{
incr
i
}
{
...
...
www/import-im_risk.tcl
View file @
c0d2a4ef
...
...
@@ -66,7 +66,6 @@ set header_fields [im_csv_split $header $separator]
set
header_len
[
llength
$header
_fields
]
set
values_list_of_lists
[
im_csv_get_values
$lines
_content
$separator
]
# ad_return_complaint 1 "<pre>[array get column
]
<br>
[
array
get map
]
<br>
[
array
get parser
]
<br>
[
array
get parser_args
]
<br>$header_fields</pre>
"
...
...
@@ -126,6 +125,15 @@ foreach csv_line_fields $values_list_of_lists {
if {
$ns
_write_p} { ns_write "
</ul><hr><ul>
\n
" }
if {
$ns
_write_p} { ns_write "
<li>Starting to parse line
$cnt
\n
" }
if {
[
llength
$csv
_line_fields
]
< 4} {
if {
$ns
_write_p} {
ns_write "
<li><font color=red>Error: We found a row with only
[
llength
$csv
_line_fields
]
columns.<br>
This is probabily because of a multi-line field in the row before.<br>Please correct the CSV file.</font>
\n
"
}
continue
}
# Preset values, defined by CSV sheet:
set risk_name ""
set risk_project_id ""
...
...
@@ -213,13 +221,13 @@ foreach csv_line_fields $values_list_of_lists {
# Status is a required field
if {"" ==
$risk
_status_id} {
if {
$ns
_write_p} { ns_write "
<li><font color=brown>Warning: Didn't find risk status '$risk_status', using default status 'Open'</font>
\n
" }
set risk_status_id
[
im_risk_status_
active
]
set risk_status_id
[
im_risk_status_
open
]
}
# Type is a required field
if {"" ==
$risk
_type_id} {
if {
$ns
_write_p} { ns_write "
<li><font color=brown>Warning: Didn't find risk type '$risk_type', using default type 'Other'</font>
\n
" }
set risk_type_id
[
im_risk_type_
default
]
set risk_type_id
[
im_risk_type_
risk
]
}
# -------------------------------------------------------
...
...
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