Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
replace text in a txt
#8
Quote:I don't see any value in putting this information in a database. A database needs to be carefully designed to be useful. If you could put this information into a database, what kind of queries would you want to perform? Use the queries to define what tables and columns you'll need in your database, then write the code to load the file into database tables. Don't create the tables first then try to figure out how to write a query.

from this txt file i need only the percentages

Verona - Napoli partita column
10.42% p1 column
27.08% px column
62.5% p2 column
37.5% p1X column
89.58% pX2 column
72.92% p12 column

so i need to create and send
inserts like
sql = "INSERT INTO sbostats (partita,p1,pX,p2,p1x,px2,p12) VALUES (%s, %s,%s, %s,%s, %s, %s)"
val = ( "Verona - Napoli", "10.42%", "27.08%","62.5%", "37.5%", "89.58%", "72.92%")
one for each 7 lines (match) of the txt file
then i will make some joins/query and view on other tables of my database.
Reply


Messages In This Thread
replace text in a txt - by cartonics - Oct-12-2023, 07:50 AM
RE: replace text in a txt - by buran - Oct-12-2023, 07:52 AM
RE: replace text in a txt - by cartonics - Oct-12-2023, 08:01 AM
RE: replace text in a txt - by buran - Oct-12-2023, 09:11 AM
RE: replace text in a txt - by perfringo - Oct-12-2023, 09:43 AM
RE: replace text in a txt - by cartonics - Oct-12-2023, 10:54 AM
RE: replace text in a txt - by deanhystad - Oct-12-2023, 08:01 PM
RE: replace text in a txt - by cartonics - Oct-13-2023, 07:31 AM
RE: replace text in a txt - by deanhystad - Oct-13-2023, 11:35 AM
RE: replace text in a txt - by cartonics - Oct-13-2023, 12:48 PM
RE: replace text in a txt - by deanhystad - Oct-13-2023, 01:27 PM
RE: replace text in a txt - by cartonics - Oct-13-2023, 02:28 PM
RE: replace text in a txt - by deanhystad - Oct-13-2023, 06:35 PM
RE: replace text in a txt - by cartonics - Oct-13-2023, 08:01 PM
RE: replace text in a txt - by deanhystad - Oct-13-2023, 08:42 PM
RE: replace text in a txt - by cartonics - Oct-14-2023, 06:33 AM
RE: replace text in a txt - by nicoali - Dec-15-2023, 06:28 PM
RE: replace text in a txt - by nicoali - Dec-16-2023, 04:07 PM
RE: replace text in a txt - by logicielfr - Jan-23-2024, 09:33 PM
RE: replace text in a txt - by Athi - Jan-30-2024, 06:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replace a text/word in docx file using Python Devan 4 3,895 Oct-17-2023, 06:03 PM
Last Post: Devan
  python-docx regex: replace any word in docx text Tmagpy 4 2,338 Jun-18-2022, 09:12 AM
Last Post: Tmagpy
  Replace String in multiple text-files [SOLVED] AlphaInc 5 8,296 Aug-08-2021, 04:59 PM
Last Post: Axel_Erfurt
  Iterate 2 large text files across lines and replace lines in second file medatib531 13 6,120 Aug-10-2020, 11:01 PM
Last Post: medatib531
  Search & Replace - Newlines Added After Replace dj99 3 3,465 Jul-22-2018, 01:42 PM
Last Post: buran
  Need to replace (remove) Unicode characters in text ineuw 1 8,663 Jan-02-2018, 08:01 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

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