GPS and sensor data logger only works when connected to serial connection

PeterH:

jmagnus:
When I take it off serial monitor(pc connection) and power it externally it does not save any data to the sd card.(there is no data when I open the .csv file)

Is that output on the SD card the only evidence that it's working? If so, I suggest you think about adding some diagnostics. Flash an LED a couple of times in setup or do something else recognisable so that you can see whether the Arduino is being reset. Make sure that your code checks for and handles all the error conditions that could occur initialising the SD card and writing to it, and find a way to make it apparent when something fails (e.g. turn an LED on solid, blink an error code, change the state of a spare output pin - do something tangible you can look for to see whether the sketch has detected any errors and if so you can then go see what type of error has occurred.

Yes, if there is no data on the SD card then that is the only way I know it failed. I have no clue how far it gets in the sketch.
The LED error code sounds like a good idea. Problem is I am a complete noob and I dont know how to do that or to check for other errors.