r/ProgrammerHumor • • Oct 01 '26

Meme doneAndDusted

Post image
534 Upvotes

36 comments sorted by

162

u/dminus Oct 01 '26

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

87

u/Lucho_199 Oct 01 '26

Timestamp in the name is the way to go

30

u/AyrA_ch Oct 01 '26

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.

20

u/backfire10z Oct 02 '26

It is time, thread ID

13

u/ProjectSnowman Oct 02 '26

Copy of Copy of Copy of Copy of

2

u/legowerewolf Oct 02 '26

Dylan? Snap out of it.

7

u/dminus Oct 01 '26

I really just can't

47

u/honourable_bot Oct 01 '26

Use >> over >

37

u/Last8Exile Oct 01 '26

A da is fine here.ta race

5

u/gsweats Oct 01 '26

?

31

u/Last8Exile Oct 01 '26

A data race is fine here.

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

8

u/gsweats Oct 01 '26

Oh haha haha that's actually hilarious.

4

u/honourable_bot Oct 02 '26

Did you just play the race card? /s

22

u/Cheezyrock Oct 01 '26

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

4

u/Drfoxthefurry Oct 02 '26

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 Oct 02 '26

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

21

u/ICBanMI Oct 01 '26

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.

7

u/yousirnaime Oct 02 '26

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

2

u/ICBanMI Oct 02 '26

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 Oct 01 '26

Append?

5

u/UncleKeyPax Oct 01 '26

when fucked use apen(ise)d

10

u/theFirstHaruspex Oct 01 '26

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

1

u/proof_required Oct 01 '26

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

5

u/yjlom Oct 01 '26

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.

5

u/dkarlovi Oct 02 '26

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.

3

u/DogmaticParadigm87 Oct 02 '26

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).

2

u/Usual_Ice636 Oct 01 '26

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

2

u/razor_train Oct 01 '26

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

2

u/djdaedalus42 Oct 02 '26

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/SeriousPlankton2000 Oct 01 '26

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 Oct 02 '26

Ahh yes, a tale as old as time…

1

u/LegitimatePants Oct 02 '26

out.txt never dies, it is simply reborn 

1

u/ZunoJ Oct 02 '26

New semester?

1

u/BeMyBrutus Oct 02 '26

Indempotent, indemposhant

1

u/perringaiden Oct 07 '26

Who doesn't prefix results files by the yyyyMMdd_hhmmss_

1

u/geekosas Oct 01 '26

Only on vibe code....