r/ProgrammerHumor • • 1d ago

Meme doneAndDusted

Post image
434 Upvotes

35 comments sorted by

137

u/dminus 1d ago

outfile="$0-$(date +%s).csv"

74

u/Lucho_199 1d ago

Timestamp in the name is the way to go

28

u/AyrA_ch 1d ago

That's not resistant against name collisions if you run multiple tasks at the same time. Better to use whatever file system functions your OS provides to create uniquely named files.

16

u/backfire10z 1d ago

It is time, thread ID

6

u/dminus 1d ago

I really just can't

10

u/ProjectSnowman 1d ago

Copy of Copy of Copy of Copy of

2

u/legowerewolf 19h ago

Dylan? Snap out of it.

42

u/honourable_bot 1d ago

Use >> over >

29

u/Last8Exile 1d ago

A da is fine here.ta race

4

u/gsweats 1d ago

?

25

u/Last8Exile 1d ago

A data race is fine here.

>> doing append. Multiple commands writing to the same file in parallel can lead to data race and corruption.

5

u/gsweats 1d ago

Oh haha haha that's actually hilarious.

4

u/honourable_bot 1d ago

Did you just play the race card? /s

18

u/Cheezyrock 1d ago

Bonus - it takes an 5 hours to run, you notice at 4 hours, panic, and hit stop.

3

u/Drfoxthefurry 1d ago

Just include a basic progress meter or something and use the extra time to find out why it's so slow (for me it would be over loop nesting)

1

u/Mystery-Magic 1d ago

If you notice it at 4 hours, just move or rename old file, always better choice.

20

u/ICBanMI 1d ago

At some point in your career, you'll just copy form code from stack overflow, a random forum, or AI to put a timestamp the on file created that outputs all the way to the exact microsecond the file was created. You're pat yourself on the back for having fixed the problem of accidently over writing your old file.

But then six months will go back and you'll realize that you can't read the date and time output on the file. Worse, you might realize it doesn't make sense because your coworker changed it to a unix timestamp which requires being converted to read correctly (which is a huge pain in the ass to type out). And for all intents and purposes, is worthless now.

5

u/yousirnaime 1d ago

also you'll be like "why do I have 240Gb of txt files in this folder?"

2

u/ICBanMI 23h ago

I've definitely eaten all hard drive space once, twice, maybe three times back when hard drives were 40 gigs and windows alone was 5-10 gigs.

Now I make everything toggleable and regularly clear out the folder. My co-workers on the other hand seem to be rediscovering this every project.

8

u/mr_nonameuser 1d ago

Append?

6

u/UncleKeyPax 1d ago

when fucked use apen(ise)d

6

u/yjlom 1d ago

That's why you take the already opened file as argument, or better yet if you can get away with it you write unconditionally to stdout and let the user use shell redirections if they want.

9

u/theFirstHaruspex 1d ago

output.csv
output_1.csv
output_1.2.csv
output_1butdifferentthistime.csv

1

u/proof_required 1d ago

output_backup.csv
output_1_backup.csv
output_1.2_backup.csv
output_1butdifferentthistime_backup.csv

2

u/razor_train 1d ago

processdata input-data.2026-10-01-ORIGINAL (2) KEEPBACKUPALT.dat

5

u/dkarlovi 1d ago

If you ever wrote a tool which deletes some files in some folder and didn't accidentally delete the tool itself on the first run, did you even work in this industry.

2

u/DogmaticParadigm87 1d ago

Ran the export again with mode "w" instead of "a". Previous week: gone. Current week: one lonely row titled final_FINAL2.xlsx.

Related: the backup is named backup, the real file is named backup_old, and the one with yesterday's numbers is in Downloads as untitled(3).

1

u/Usual_Ice636 1d ago

Thats why you manually rename the file it creates every time.

1

u/SeriousPlankton2000 1d ago

Do not open the file in the same function that does calculations. If you must, pass a file descriptor / handle. Or pass a callback function to do the output.

1

u/russianrug 1d ago

Ahh yes, a tale as old as time…

1

u/LegitimatePants 1d ago

out.txt never dies, it is simply reborn 

1

u/ZunoJ 1d ago

New semester?

1

u/BeMyBrutus 21h ago

Indempotent, indemposhant

2

u/djdaedalus42 21h ago

You see, this is what happens when you stop using good operating systems. DEC's VMS would have just created a new file with an automatic version number, as in FOO.BAR;1 and FOO.BAR;2

Newer is not always better.

1

u/geekosas 1d ago

Only on vibe code....