Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable list
#1
Hi!

I'm brand new to python FYI.

I'm trying to create a text list with a changing variable on each line e.g.
Output:
example001test001 example002test002 example003test003 ...
So far, from searching online I've got as far as this:
values = "example{}test{}"
id = ["%.3d" % i for i in range(1, 100)]
result = values.format(id, id)
outputfile = "Z:\RESULT.csv"
import csv
with open(csvfile, "w") as output:
    writer = csv.writer(output, lineterminator='\n')
    for val in links:
        writer.writerow([result]) 
The problem is when I run this it isn't exporting the variables one per line, it's showing the whole list on each line instead. Any ideas?

Many thanks!
Reply


Messages In This Thread
Variable list - by Ivan86 - Aug-18-2018, 09:02 PM
RE: Variable list - by nilamo - Aug-18-2018, 09:13 PM
RE: Variable list - by ichabod801 - Aug-18-2018, 09:13 PM
RE: Variable list - by Ivan86 - Aug-18-2018, 09:17 PM
RE: Variable list - by nilamo - Aug-18-2018, 09:55 PM
RE: Variable list - by ichabod801 - Aug-18-2018, 09:59 PM
RE: Variable list - by Ivan86 - Aug-18-2018, 10:37 PM
RE: Variable list - by ichabod801 - Aug-18-2018, 11:16 PM
RE: Variable list - by Ivan86 - Aug-19-2018, 07:21 AM
RE: Variable list - by snippsat - Aug-19-2018, 12:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split string using variable found in a list japo85 2 1,315 Jul-11-2022, 08:52 AM
Last Post: japo85
  An IF statement with a List variable dedesssse 3 8,314 Jul-08-2021, 05:58 PM
Last Post: perfringo
  Create variable and list dynamically quest_ 12 4,451 Jan-26-2021, 07:14 PM
Last Post: quest_
Question Matching variable to a list index Gilush 17 5,931 Nov-30-2020, 01:06 AM
Last Post: Larz60+
  Print variable values from a list of variables xnightwingx 3 2,655 Sep-01-2020, 02:56 PM
Last Post: deanhystad
  Multiplication between a list and a variable doug2019 2 2,180 Oct-08-2019, 04:10 AM
Last Post: doug2019
  Sub: Python-3: Better Avoid Naming A Variable As list ? adt 9 4,053 Aug-29-2019, 08:15 AM
Last Post: adt
  Score each word from list variable pythonias2019 6 3,382 Jun-13-2019, 05:44 PM
Last Post: gontajones
  How to store the value from variable into list & run a statement then put in variable searching1 1 2,472 May-29-2019, 06:36 AM
Last Post: heiner55
  copy list into variable poroton 1 2,615 Aug-10-2018, 07:19 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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