title: What do I need to do to write a .csv file to a shared network folder? (Raspberry Pi & Python)
body: <p>I have 2 raspberry pis and a windows computer all on the same network. I have one raspberry pi set up as a NAS, and I want the other raspberry pi to run a program and then write a csv file containing data to a samba share on the NAS pi. Then I would be able to access the file from my windows computer and open it.</p>
  
  <p>The following code will write the csv file called "lights.csv" to the desktop of the 2nd raspberry pi: </p>
  
  <pre><code>outputFile = open('lights.csv', 'w')
  for i in range(len(button_array)):
      #Convert the button's time_on variable to a string and append a comma and newline.
      outputFile.write(str(button_array[i].total_time_on) + ',\n')
  
  outputFile.close()
  </code></pre>
  
  <p>Is it a simple coding edit that I need? Do I need to import another Python module? Will this involve somehow "mapping the network drive?" I have not found a straight answer for this anywhere else, so I am trying to be as specific as possible. I also don't want to copy the file there (by using shutil), I want it to save/write it directly to that network folder, which is then shared using Samba.  </p>
  
  <p>Please be specific, and if possible, please show some example code for it. I am just a novice (at best) when it comes to Python, Linux, and networking. Thank you in advance.</p>