Python Forum
Write only data not >> () << parentheses
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write only data not >> () << parentheses
#1
I need save data in csv file, but only data.

Look in quote below, how data is save in file.

from itertools import combinations

jogadores = []
f = open('C:\\Users\\zinho\\PycharmProjects\\sinuca\\jogadores.csv', 'rU')
for line in f:
    Cells = Line.Split(",")
    jogadores.append((cells[1]))

f.close()

jogos = [c for c in combinations(jogadores[1:], 2)]

with open('outPare.txt', 'a') as out:
    for i in jogos:
        out.write(str(i) + '\n')
Quote:
My code save data this way <-> I want save data this way
('Mateus Sino\n', 'Jean Peter\n') <-> Mateus Sino, Jean Peter
('Mateus Sino\n', 'Lucas Guarnieri\n') <-> Mateus Sino, Lucas Guarnieri
('Mateus Sino\n', 'Lucas Sino\n') <-> Mateus Sino, Lucas Sino
('Mateus Sino\n', 'Wagner Correas\n') <-> Mateus Sino, Wagner Correas
('Mateus Sino\n', 'Julivan Silva\n') <-> Mateus Sino, Julivan Silva
('Mateus Sino\n', 'Robson Caitano\n') <-> Mateus Sino, Robson Caitano
('Mateus Sino\n', 'Wellington Lopes\n') <-> Mateus Sino, Wellington Lopes
('Jean Peter\n', 'Lucas Guarnieri\n') <-> Jean Peter, Lucas Guarnieri
('Jean Peter\n', 'Lucas Sino\n') <-> Jean Peter, Lucas Sino
('Jean Peter\n', 'Wagner Correas\n') <-> Jean Peter, Wagner Correas
('Jean Peter\n', 'Julivan Silva\n') <-> Jean Peter, Julivan Silva
('Jean Peter\n', 'Robson Caitano\n') <-> Jean Peter, Robson Caitano
('Jean Peter\n', 'Wellington Lopes\n') <-> Jean Peter, Wellington Lopes
('Lucas Guarnieri\n', 'Lucas Sino\n') <-> Lucas Guarnieri, Lucas Sino
('Lucas Guarnieri\n', 'Wagner Correas\n') <-> Lucas Guarnieri, Wagner Correas
('Lucas Guarnieri\n', 'Julivan Silva\n') <-> Lucas Guarnieri, Julivan Silva
('Lucas Guarnieri\n', 'Robson Caitano\n') <-> Lucas Guarnieri, Robson Caitano
('Lucas Guarnieri\n', 'Wellington Lopes\n') <-> Lucas Guarnieri, Wellington Lopes
('Lucas Sino\n', 'Wagner Correas\n') <-> Lucas Sino, Wagner Correas
('Lucas Sino\n', 'Julivan Silva\n') <-> Lucas Sino, Julivan Silva
('Lucas Sino\n', 'Robson Caitano\n') <-> Lucas Sino, Robson Caitano
('Lucas Sino\n', 'Wellington Lopes\n') <-> Lucas Sino, Wellington Lopes
('Wagner Correas\n', 'Julivan Silva\n') <-> Wagner Correas, Julivan Silva
('Wagner Correas\n', 'Robson Caitano\n') <-> Wagner Correas, Robson Caitano
('Wagner Correas\n', 'Wellington Lopes\n') <-> Wagner Correas, Wellington Lopes
('Julivan Silva\n', 'Robson Caitano\n') <-> Julivan Silva, Robson Caitano
('Julivan Silva\n', 'Wellington Lopes\n') <-> Julivan Silva, Wellington Lopes
('Robson Caitano\n', 'Wellington Lopes\n') <-> Robson Caitano, Wellington Lopes
Reply
#2
Something like this.
>>> s = ('Mateus Sino\n', 'Jean Peter\n')
>>> ', '.join(s).replace('\n', '')
'Mateus Sino, Jean Peter'
Reply
#3
LOL

Very, very good!

Thank you!!!!!!!!! Big Grin
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Write sql data or CSV Data into parquet file mg24 2 2,453 Sep-26-2022, 08:21 AM
Last Post: ibreeden
  Is this possible to write a script for checking data from website? WanW 2 1,132 Jun-02-2022, 02:31 AM
Last Post: Larz60+
  Write and read back data Aggie64 6 1,907 Apr-18-2022, 03:23 PM
Last Post: bowlofred
Lightbulb [Solved] df.loc: write data in certain rows ju21878436312 1 1,719 Jun-28-2021, 06:49 AM
Last Post: ju21878436312
  Unable to Validate csv blanck data and write in csv prashant18 0 1,545 Jul-25-2020, 12:08 PM
Last Post: prashant18
  Read and write data to CSV files kartik 1 1,893 Mar-12-2019, 06:16 AM
Last Post: Yoriz
  write csv data into teradata table sandy 0 5,128 Feb-13-2019, 12:11 AM
Last Post: sandy
  I can't write my data to the data file , Why? canatilaa 4 2,736 Jan-08-2019, 10:50 PM
Last Post: canatilaa
  read select data from one file and write to another Shameendra 1 2,501 Oct-16-2018, 06:46 PM
Last Post: ichabod801
  SyntaxError: Missing parentheses in call to 'print' sofret 3 6,885 Jun-15-2018, 03:23 PM
Last Post: buran

Forum Jump:

User Panel Messages

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