Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Fool
Oct 16, 2003


Necrobama posted:

Part of me is screaming at me "JUST LEARN POWERSHELL!"? Is that part right?

No.

I am normally a powershell evangelist, but python/pandas is the right tool for the job here.

Adbot
ADBOT LOVES YOU

The Fool
Oct 16, 2003


When I was doing something similar, I don't remember having to do anything with actual SQL statements, pandas did it all for me.

Are you just loading the csv's into the tables as is?

df.to_sql should create and insert for you

The only real issue I ran into was managing types, and the solution I went with was to have a dict with a list of column names and types.

Would require knowing that info ahead of time.

The Fool
Oct 16, 2003


Necrobama posted:


I'll dig a big more into the documentation on to_sql though, I recall looking briefly at that as an option at one point but my desire for absolute control over the table creation I think won out; thanks for the suggestion!

the dtype argument lets you specify column types and take a dict

The Fool
Oct 16, 2003


vs code has a whole remote workspace thing where you can point it at any vm or container with ssh

The Fool
Oct 16, 2003


that's something I end up doing a few times a year at work

use python to collect and sanitize your data, then deliver in whatever form your audience is more likely to use

sadly for me that is often power bi

The Fool
Oct 16, 2003


Foxfire_ posted:

Does human editable mean 'editable by a programmer' (use something standard like everyone else has said) or 'editable by Bob from Marketing who needs explicit very friendly error messages on typos'?

code:
pd.DataFrame(data).to_excel('output.xlsx', index=False)

The Fool
Oct 16, 2003


Unless you have anything that looks like a date string in your cells.

I used an open source csv editor once a long time ago, it did not have a smaller footprint than excel, and was worse in almost every way.

I feel like if excel is not going to work, the best option is to load it into a dict or a dataframe, do what you need to do in a jupyter notebook, then generate a new csv.

The Fool
Oct 16, 2003


tangentially related, is there a good way to generate a requirements.txt that only has what is being imported in my working directory and not everything in my entire environment

The Fool
Oct 16, 2003


necrotic posted:

pip freeze doesn’t look at your imports, just what’s installed. The point is to have _every_ dependency pinned.

I understand that which is the entire point of my question.

The Fool
Oct 16, 2003


CarForumPoster posted:

Requirements.txt is usually made by pip freeze or by hand as you install stuff so you can maintain orders and versions. What’s being imported doesn’t necessarily have 1:1 naming with the package name on pip.

So maybe, but there’s likely going to be a lot of issues with that a year or two from now if the environment needs to get reinstalled.

My issue is that my local workstation has a million unrelated things installed and I never did a good job of managing venvs.

So when I write a thing to be deployed and need a requirements.txt I have to do it by hand right now and it's annoying.

The Fool
Oct 16, 2003


just use pandas

The Fool
Oct 16, 2003


simple python envs work fine in windows

depending on what you're doing some packages may not work cleanly

that being said, my daily driver is a windows machine but I do 90% of my work in WSL or a docker container.

The Fool
Oct 16, 2003


Doing your build in docker is not a terrible idea except for the fact that windows containers are horrible.

The Fool
Oct 16, 2003


should be able to use capture groups: https://docs.python.org/3/library/re.html#re.Match.group

The Fool
Oct 16, 2003


Tacos Al Pastor posted:

Thats awesome, but I dont want to store them in a tuple but rather a list.

iterate the lines, if it does't match it returns None, if it does it returns group(0) as a string, append to your list

The Fool
Oct 16, 2003


flask binds to 127.0.0.1 by default, you can change that by using the --host flag

The Fool
Oct 16, 2003


fwiw I absolutely hate the tone of parts of the foundation documentation

Adbot
ADBOT LOVES YOU

The Fool
Oct 16, 2003


Yes, use playwright
https://playwright.dev/python/

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply