Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Carlos-Francisco Méndez-Cruz
/
automatic-extraction-growth-conditions
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Carlos-Francisco Méndez-Cruz
2019-03-19 16:03:23 -0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
04e9d0330e8f5bb290afd8ae458dfe706e00b047
04e9d033
1 parent
89fe6c52
Transform soft file in XML file
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
scripts/soft-2-xml.py
scripts/soft-2-xml.py
View file @
04e9d03
...
...
@@ -18,9 +18,11 @@ __author__ = 'CMendezC'
# Execution:
# python soft-2-xml.py
# --inputPath C:\Users\cmendezc\Documents\GENOMICAS\gitlab_automatic-extraction-growth-conditions\data-sets\soft-data
# --inputPath C:\Users\cmendezc\Documents\GENOMICAS\gitlab_automatic-extraction-growth-conditions\data-sets\soft-data
-additional
# --outputPath C:\Users\cmendezc\Documents\GENOMICAS\gitlab_automatic-extraction-growth-conditions\data-sets\xml-data
# python soft-2-xml.py --inputPath C:\Users\cmendezc\Documents\GENOMICAS\gitlab_automatic-extraction-growth-conditions\data-sets\soft-data --outputPath C:\Users\cmendezc\Documents\GENOMICAS\gitlab_automatic-extraction-growth-conditions\data-sets\xml-data
# Additional files
# python soft-2-xml.py --inputPath C:\Users\cmendezc\Documents\GENOMICAS\gitlab_automatic-extraction-growth-conditions\data-sets\soft-data-additional --outputPath C:\Users\cmendezc\Documents\GENOMICAS\gitlab_automatic-extraction-growth-conditions\data-sets\xml-data
###########################################################
# MAIN PROGRAM #
...
...
@@ -45,13 +47,14 @@ if __name__ == "__main__":
print
(
"Path to place output files: "
+
str
(
options
.
outputPath
))
# Walk directory to read files
processedFiles
=
0
for
path
,
dirs
,
files
in
os
.
walk
(
options
.
inputPath
):
for
f
in
files
:
if
f
.
endswith
(
"_family.
tx
t"
):
if
f
.
endswith
(
"_family.
sof
t"
):
print
(
"Processing...{}/{}"
.
format
(
options
.
inputPath
,
f
))
softText
=
''
with
open
(
os
.
path
.
join
(
options
.
inputPath
,
f
),
"r"
,
encoding
=
"utf-8"
,
errors
=
"replace"
)
as
iFile
:
with
open
(
os
.
path
.
join
(
options
.
outputPath
,
f
.
replace
(
".
tx
t"
,
".xml"
)),
"w"
,
with
open
(
os
.
path
.
join
(
options
.
outputPath
,
f
.
replace
(
".
sof
t"
,
".xml"
)),
"w"
,
encoding
=
"utf-8"
)
as
oFile
:
oFile
.
write
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n\n
<gse xmlns:xsi=
\"
http://www.w3.org/2001/XMLSchema-instance
\"\n
xsi:noNamespaceSchemaLocation=
\"
esquema-gcs.xsd
\"
>
\n\n
"
)
for
line
in
iFile
:
...
...
@@ -62,4 +65,5 @@ if __name__ == "__main__":
# line = line.replace("\'", "'")
oFile
.
write
(
line
)
oFile
.
write
(
"
\n
</gse>
\n
"
)
processedFiles
+=
1
print
(
"Processed files: {}"
.
format
(
processedFiles
))
...
...
Please
register
or
login
to post a comment