Search code examples
pythonpython-3.xcsvcsvreader

Remove Brackets and Single quotes from list loaded from CSV file


I am opening a .csv file that contains links and I want to navigate to each one. But when i print the list of links, it has brackets and single quotes around them. How do I print the links without the brackets and single quotes?

import csv
import os

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links = list(reader)

for i in links:
    print(i)

Results

['https://links.com/100GLC-PFAQ-6X9?idc=43']
['https://links.com/100GLC-PFAQ-9X12?idc=43']
['https://links.com/100LB-PFLIN-9X12?idc=43']
['https://links.com/14PT-PFUV-5.25X10.5?idc=43']
['https://links.com/14PT-PFUV-6X9?idc=43']
['https://links.com/14PT-PFUV-9X12?idc=43']

UPDATE I solved the issue using the *. Below is my updated code.

import csv
import os

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links = list(reader)

for i in links:
    print(*i)

Solution

  • I solved the issue using the *. Below is my updated code.

    import csv
    import os
    
    with open('links.csv', 'r') as f:
      reader = csv.reader(f)
      links = list(reader)
    
    for i in links:
        print(*i)