There is a lot of ways to do this, and the best one depends on how will you use the generated data. Not having all the details of your particular setup, I'll assume the following:
You want a regular text file stored with incoming data appended to the file.
You have already properly connected Arduino and RPi so you receive, say, a stream of characters on a buffer on the RPi.
Let's say you have your incoming string made available into your python script via a call to a function called get_arduino_string()
that returns the string being read, or None if there is nothing more to read (I'll asume that you already have this developed as you say you have already interfaced both devices.)
In this situation, this python script would create a file into the RPi filesystem and append the readings to it:
def get_arduino_string():
... code for reading the string from the arduino...
if __name__ == "__main__":
f=open('filename','a') # 'a' is for append
reading=get_arduino_string() # get the reading from the arduino
while reading is not None: # loop while we get a string from arduino
f.write(reading) # write the string into the file
reading=get_arduino_string() # read a new string
f.close() # close the file when nothing more to receive
This is a very basic script without exception handling, but gives an idea about how to generate this file. In this case this is a text file. You could see live what's being written in the file by issuing a
tail -f filename
from the RPi's shell prompt while the script is running in another shell, or in background.
Being this a regular (unix) text file, you can do whatever you want with it. You can transfer it to another machine, send it by mail, or directly process it from within the RPi. For example, if you want to process the file line by line, you could run the following python script:
f=open('filename','r') # open for read
lines=f.readlines() # read the contents of the file into the variable lines
for line in lines: # loop for each line of the file
print line # print the contents
.... # or process its contents
f.close() # close the file