Commit 1fc005a2 authored by Marie FU's avatar Marie FU

update Element to tsv and correct clean csv

parent 093cc8b3
...@@ -176,8 +176,7 @@ if STATE.file is not None: ...@@ -176,8 +176,7 @@ if STATE.file is not None:
toStartOfFile(STATE.file) toStartOfFile(STATE.file)
STATE.fileData = "" STATE.fileData = addColumnsNamestoTSV(STATE.file, STATE.encoding, STATE.separator,STATE.columnMap)
addColumnsNamestoTSV(STATE.file, STATE.encoding, STATE.separator,STATE.columnMap)
toStartOfFile(STATE.file) toStartOfFile(STATE.file)
...@@ -236,8 +235,7 @@ if STATE.file is not None: ...@@ -236,8 +235,7 @@ if STATE.file is not None:
errors += file + ": " + STATE.general_text_dict['err_columns'] + "\n" errors += file + ": " + STATE.general_text_dict['err_columns'] + "\n"
else: else:
STATE.fileData = "" STATE.fileData = addColumnsNamestoTSV(STATE.currentFile, STATE.encoding, STATE.separator,STATE.columnMap)
addColumnsNamestoTSV(STATE.currentFile, STATE.encoding, STATE.separator,STATE.columnMap)
# set a variable to check if there are any detected errors # set a variable to check if there are any detected errors
# and construction of correct file content while checking # and construction of correct file content while checking
...@@ -250,7 +248,7 @@ if STATE.file is not None: ...@@ -250,7 +248,7 @@ if STATE.file is not None:
else: else:
with open(STATE.zipDir.name+"/CleanCSV/"+file[:-4]+".tsv","w") as file: with open(STATE.zipDir.name+"/CleanCSV/"+file[:-4]+".tsv","w") as file:
file.write(STATE.fileData.replace("\"","”")) file.write(STATE.fileData.replace("\"","”"))
if STATE.allFileData != "": if STATE.allFileData == "":
STATE.allFileData = STATE.fileData STATE.allFileData = STATE.fileData
else: else:
STATE.allFileData += STATE.fileData[81:] STATE.allFileData += STATE.fileData[81:]
......
This diff is collapsed.
...@@ -7,8 +7,6 @@ Authors: ...@@ -7,8 +7,6 @@ Authors:
from io import StringIO from io import StringIO
import typing import typing
from anyio import open_file
from numpy import isin
from streamlit.runtime.uploaded_file_manager import UploadedFile from streamlit.runtime.uploaded_file_manager import UploadedFile
import streamlit as st import streamlit as st
from src.gerneralFileOP import * from src.gerneralFileOP import *
...@@ -237,7 +235,7 @@ def addColumnsNamestoTSV(file : UploadedFile|str, encoding : str, separator : st ...@@ -237,7 +235,7 @@ def addColumnsNamestoTSV(file : UploadedFile|str, encoding : str, separator : st
filecontent = StringIO(file.getvalue().decode(encoding)).read().split("\n")[0].split(separator) filecontent = StringIO(file.getvalue().decode(encoding)).read().split("\n")[0].split(separator)
elif isinstance(file, str): elif isinstance(file, str):
with open(file, "r", encoding=encoding) as f: with open(file, "r", encoding=encoding) as f:
filecontent = f.read() filecontent = f.read().split(separator)
for name in filecontent : for name in filecontent :
if name in columnMap.keys(): if name in columnMap.keys():
if fileData != "": if fileData != "":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment