Python Forum
Importing data from a text file into an SQLite database with Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing data from a text file into an SQLite database with Python
#6
what I show you - is better. Obviously separator is '##'.
spam ='2020-05-22##18:00:00###RANGE ###RANGE ###RANGE ##201828##190182##96136##2  ##0  ###RANGE ###RANGE ##532387##644##313415'
eggs = [ele.strip() for ele in spam.split('##') if not ele.startswith('#RANGE')]
print(eggs)
Output:
['2020-05-22', '18:00:00', '201828', '190182', '96136', '2', '0', '532387', '644', '313415']
It's not clear if there could be case where instead of '#RANGE' you have a valid value and you need to handle such case.

for sqlite look at sqlite3 module
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Importing data from a text file into an SQLite database with Python - by buran - Jun-29-2020, 07:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  wrong entries in sqlite database and tkinter epsilondatum 2 409 Apr-23-2024, 04:48 PM
Last Post: epsilondatum
  need help with data analysing with python and sqlite Hardcool 2 415 Jan-30-2024, 06:49 AM
Last Post: Athi
  Replace a text/word in docx file using Python Devan 4 3,728 Oct-17-2023, 06:03 PM
Last Post: Devan
  python sqlite autoincrement in primary column janeik 6 1,250 Aug-13-2023, 11:22 AM
Last Post: janeik
  save values permanently in python (perhaps not in a text file)? flash77 8 1,288 Jul-07-2023, 05:44 PM
Last Post: flash77
  How to detect abnormal data in big database python vanphuht91 5 1,186 Jun-27-2023, 11:22 PM
Last Post: Skaperen
  Database that can compress a column, or all data, automatically? Calab 3 1,256 May-22-2023, 03:25 AM
Last Post: Calab
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,169 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  New2Python: Help with Importing/Mapping Image Src to Image Code in File CluelessITguy 0 743 Nov-17-2022, 04:46 PM
Last Post: CluelessITguy
  python standard way of importing library mg24 1 944 Nov-15-2022, 01:41 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020