Search
Searches topics and replies. Every word has to appear in the post.
50 posts found.
| Post | Posted |
|---|---|
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 |
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 |
Of course. | by lintroller !-TjZOnKc |
ok. no requirements file of course | by mo |
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 |
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 |
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 |
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 |
Thanks, had the same thing with a script exporting addresses. newline="" did it. | by Anonymous |
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 |
Worked first try. Resolved. | by Anonymous |
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 |
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 |
oh that is way easier. thanks, had given up on this | by pbj |
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 |
So it's fine as long as I round when showing it. That's a relief. thanks! | by bea |
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 |
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 |
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 |
bump again. anyone? | by pbj |
Java's Double.compare does give NaN a total order. Rare win for the old thing. | by gcfail |
Same in every language with IEEE floats and a comparison sort. JS is worse because sort() defaults to comparing strings. | by lintroller !-TjZOnKc |
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 |
bump | by pbj |
need last errors first. file is like 3gb. readlines runs out of memory | by pbj |