Writing values to seperate files

Typically: "How do I... ", "How can I... " questions
Post Reply
chathu1
Posts: 17
Joined: 03 Jun 2023, 01:05

Writing values to seperate files

Post by chathu1 »

I want to write values to two separate cvs files at the same. When I use "file:write()" to specify the value that I write to the file, how do I specify which file it should be on?

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: Writing values to seperate files

Post by coppelia »

Hello,

simply open two different files, e.g.:

Code: Select all

file1 = io.open('file1.txt', 'w+')
file1:write('write this to file 1')
file2 = io.open('file2.txt', 'w+')
file2:write('write this to file 2')
Cheers

Post Reply