Home>
I am having a hard time processing after reading the DAT data with f = open (file_text.get (),'r').
What i am looking for ...
1. I want to skip the first line
2. The content of DAT data is a list of such numbers.
[20395089035130095 0258387190000927700000520090015]
I want to extract the bold part from this like the first and second columns
3. Finally, I want to output as CSV
I am wandering into an unfamiliar DAT file. Thanking you in advance.
import tkinter as tk #GUI library
import tkinter.messagebox as tkm
from pathlib import Path # Library that can handle file system paths
import pandas as pd #csv Library to handle
import datetime as dt
import cx_Oracle
from tkinter import file dialog
now = dt.datetime.now () #time
time = now.strftime ('% Y% m% d-% H% M% S')
def OpenFileDlg (tbox):
ftype = [('','*')]
dir ='.'
#File dialog display
filename = filedialog.askopenfilename (filetypes = ftype, initialdir = dir)
#Display file path in text box
tbox.insert (0, filename)
def btn_click (): #button function
cc = str (txt1.get ()) # Substitute text box characters for cc
sc = str (txt2.get ())
if not len (cc) == 6:
tkm.showerror ("Enter error", "Customer number is 6 digits")
return
elif not len (sc) == 7:
tkm.showerror ("Enter error", "Employee number is 7 digits")
return
elif file_text.get () =='':
tkm.showerror ('error','specify data file')
return
else: else:
tkm.showinfo ("Information", "Saving CSV")
f = open (file_text.get (),'r')
root = tk.Tk () #Tk class generation
root.geometry ('500x400 + 600 + 300') #screen size + position
root.title ('input screen') # screen title
#Customer number
lbl1 = tk.Label (text ='customer number', font = (u'MS Gothic', 11,'bold'))
lbl1.place (x = 85, y = 145)
txt1 = tk.Entry (width = 30)
txt1.place (x = 160, y = 150)
btn = tk.Button (root, text ='CSV output', width = 20, font = ("Menlo", 11), command = btn_click)
btn.place (x = 155, y = 220)
#employee number
lbl2 = tk.Label (text ='employee number', font = (u'MS Gothic', 11,'bold'))
lbl2.place (x = 85, y = 175)
txt2 = tk.Entry (width = 30)
txt2.place (x = 160, y = 180)
btn1 = tk.Button (root, text = "end", width = 20, font = ("Menlo", 11), command = root.destroy)
btn1.place (x = 155, y = 250)
#Excel file dialog
label = tk.Label (root, text ='data file', font = (u'MS Gothic', 10,'bold'))
label.place (x = 100, y = 95)
file_text = tk.Entry (root, width = 40)
file_text.place (x = 100, y = 115)
fdlg_button = tk.Button (root, text ='file selection', command = lambda: OpenFileDlg (file_text))
fdlg_button.place (x = 360, y = 110)
root.mainloop () # screen display
-
Answer # 1
Related articles
- reading and displaying npy format files in python
- python - read multiple audio files (wav files)
- processing using the len function when an integer value is obtained from python standard input
- python - about multiple processing and loop processing in discordpy
- parallel processing using python multiprocessingpool and multiprocessingqueue does not work well
- python:about processing such as timesleep and wxpython
- python google drive api 100mb or more files cannot be uploaded
- python - avoid processing when duplicated
- emacs - (python) i want to automate the work of reading files in order
- python iterative processing num is not defend
- python - while syntax processing
- python - i want to handle files with the path obtained by ospathjoin
- python about iterative processing with specified numbers
- python - speech processing typeerror:'int' object is not subscriptable
- reading python files
- i want to add processing to the python library
- python - about range and int type processing
- python 3x - update processing and multi-process with pyqtgraph
- about reading xls files with python pandas
Related questions
- python : The problem that the string becomes a date in csv
- python : How to read only the required columns of a table in a CSV file?
- python : Error when serializing json from file
- Changing an element in a data file using Python
- python : How to set a date condition in a query with where? [duplicate]
- python : How to make it so that after processing each line in the .csv file, it deletes the previous one?
- python : how to save a dictionary in csv in each line, I get it through a line when I open it through Excel
You can flexibly read fixed-length files using pandas.read_fwf.