Progrider

Programming discussion

Search

Searches topics and replies. Every word has to appear in the post.

50 posts found.

PostPosted
Handoffs · post #1

For whoever picks this up (probably me in a month): - export.py reads readings.db and writes readings.csv, runs from systemd nightly - garage sensor reports every 15 min, porch every 5, the CSV has both - the --since flag works but isn't us…


by dan_r
Help · post #5

sorted, rebuilt all four. they each have a requirements.txt now. also found out pip outside a venv refuses to run, says externally managed environment. fine by me.


by mo
Help · post #4

Of course.


by lintroller !-TjZOnKc
Help · post #3

ok. no requirements file of course


by mo
Help · post #2

bin/python is a symlink to the system python3.11, which isn't there now. ls -l will show it's dangling. A venv isn't portable across Python versions anyway, the packages are in lib/python3.11. Recreate it. The old site-packages folder is st…


by oldpc
Help · post #1

went from 12 to 13. now every venv gives "No such file or directory" when i try to run bin/python even though the file is right there in ls


by mo
Handoffs · post #2

Trim before the comment, I'd say. Otherwise key=value ; note leaves trailing space on the value and someone will compare it. Quoted values can come later.


by jf
Handoffs · post #1

Continuing from the earlier handoff. Rule: a ; or # starts a comment only if it's preceded by whitespace or at the start of the line. So path=/tmp/a;b stays intact and key=value ; note strips the note. Tests added for both. Remaining: quote…


by Anonymous
Findings · post #2

Thanks, had the same thing with a script exporting addresses. newline="" did it.


by Anonymous
Findings · post #1

Leaving this here because I spent an hour on it. My Python CSV export had blank lines between every record when opened on Windows. Opening the output with newline="" fixed it: with open("out.csv", "w", newline="") as f: writer = csv.writer(…


by Anonymous
Help · post #3

Worked first try. Resolved.


by Anonymous
Help · post #2

The csv module in the standard library. csv.reader handles quotes and embedded commas. Open the file with newline="" for reading too, same reason as writing.


by Anonymous
Help · post #1

Splitting lines on commas breaks on rows like: "Smith, John",42,"Portland, OR" I know I should use a real parser. Which one, in Python, and does it handle the Windows line ending thing from the other thread?


by Anonymous
Help · post #5

oh that is way easier. thanks, had given up on this


by pbj
Help · post #4

Not python but tac big.log | grep ERROR | head from the shell does what you want and stops early. In Python you can seek to the end and read blocks backwards, splitting on newlines, but it's a pain to get right around the block boundary. I'…


by mo
Help · post #4

So it's fine as long as I round when showing it. That's a relief. thanks!


by bea
Help · post #3

For grades, that's fine. If it's money, don't use floats at all. Keep integer cents or use decimal.Decimal, and construct it from strings: Decimal("0.1"). Decimal(0.1) has the float's error in it already.


by lintroller !-TjZOnKc
Help · post #2

No, it's how floats work. Most decimal fractions can't be stored exactly in binary, same way 1/3 can't be written exactly in decimal. Try 0.1 + 0.2 in Python. For display use round(x, 2) or a format string like f"{x:.1f}".


by mo
Help · post #1

Adding up marks that have decimals and then the total is sometimes 79.99999999 instead of 80. Is my computer broken? The numbers are like 12.1 and 7.3.


by bea
Help · post #3

bump again. anyone?


by pbj
Findings · post #3

Java's Double.compare does give NaN a total order. Rare win for the old thing.


by gcfail
Findings · post #2

Same in every language with IEEE floats and a comparison sort. JS is worse because sort() defaults to comparing strings.


by lintroller !-TjZOnKc
Findings · post #1

Pipeline output looked sorted except where it obviously wasn't. Took me a while to narrow down. >>> nan = float('nan') >>> sorted([3, nan, 1, 2]) [3, nan, 1, 2] All comparisons with NaN return False, so sorted's assumption that < is a consi…


by lena_w
Help · post #2

bump


by pbj
Help · post #1

need last errors first. file is like 3gb. readlines runs out of memory


by pbj
All times shown in UTC.