#๐Ÿ”’ Matching data from two files and outputting into a new file issue

91 messages ยท Page 1 of 1 (latest)

vapid salmonBOT
#

@civic gate

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

civic gate
#

oh, did the attached code .txt file delete my message?

#

aaaaah

worthy summit
#

!paste

vapid salmonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

civic gate
#

thank u i will reupload using this

worthy summit
#

@civic gate we use this for code

civic gate
#

Im trying to write a function that would take data from a new input file, and parse this data using the previous two output files, taking data from the second functions output and writing it into the previous output file from the first function

worthy summit
civic gate
#

so i can remove the filepath? that would help alot tbh

#

i had the encoding because i was getting errors surrounding it

worthy summit
civic gate
#

ok thank u

worthy summit
#

also what is this for?

#

what are you trying to achieve with this?

civic gate
#

So i have the first function taking raw data from input.txt (file A1) and filtering and arranging it then written into output.txt (file B1)

The second function takes raw data from groupinput.txt (file A2) and again filters and arranges it so it only shows the relevant data into groupoutput.txt (file B2)

I need a third function that now takes data from a new file, file A3 and uses file B2 and file B1 to write it into file B3 by matching the data in the two files to arrange it into B3

#

the way it filters and arranges the data i can figure out i reckon im just unsure on how to go about this initial idea

civic gate
#

also a personal project as Im trying to pick coding back up again since finishing my college course 2 years ago

worthy summit
civic gate
#

thank you <3

civic gate
worthy summit
#

so that's an intersection if you're familiar with set theory and venn diagrams

civic gate
#

venn diagrams yes set theory no ๐Ÿคฃ

worthy summit
civic gate
#

iv just had a quick look, looks like there is an intersection() method

#

would i be using this?

worthy summit
#

you can also use the ampersand operator

robust gorge
#

one more question, what kind and volume of data are we talking about?

worthy summit
#

!e ```py
a = {1, 2, 5}
b = {5, 2, 3}

print(a & b)

vapid salmonBOT
civic gate
#

about 300 lines of plaintext

#

max in each file

robust gorge
#

okay, then it's pretty easy

#

no problem fitting it all in ram at the same time then ๐Ÿ‘

civic gate
worthy summit
civic gate
#

yeah im not doing anything on a large scale, its just very long time consuming admin work that kills my soul ๐Ÿคฃ

civic gate
#

bout 2 hours a day of organizing data manually

worthy summit
civic gate
#

and i realised i can just make a script do it with some copypasted input files

worthy summit
civic gate
#

iv been referencing that from time to time

robust gorge
civic gate
#

but iv found stackoverflow to be most helpful

#

mainly with the errors iv experienced, i have that shadow variable issue but it isnt causing any problems at the moment

#

so il sort that out once i have the entire process coded

worthy summit
#

steering back on track - is there anything else you need help with?

#

any errors, complications, logic errors?

civic gate
#

no the intersection method tip should steer me in the right direction thank u both for your help <3

robust gorge
#

no problems reading in and wringing out files at least, right?

civic gate
#

i did at first but i fixed that, it was an issue with not specifying the encoding

robust gorge
#

and you are doing so with a context manager (beginning the line with with) so that you don't need close()

civic gate
#

yeah

#

btw not entirely relevant since this is a python discord, could this be done in java too

#

that was what i was taught in my course 2 years ago i kinda want to recreate it afterwards sometime in that langauge if thats possible

robust gorge
#

sure, but python is really perfect for this

civic gate
#

yeah i saw it was gonna be used in my upcoming uni degree im starting so thought it would be a good place to start

robust gorge
#

you can do this in most normal/serious languages

#

python or java in uni?

civic gate
#

python

#

i did a IT course at college that taught java for its programming classes, starting a part time mathematics degree which uses python

#

but yeah thank u both <3 il archive this thread if i can do that idk

robust gorge
#

you'll find many commonalities between many languages

civic gate
#

i like that i have to write less in python

#

java was quite annoying tbh

robust gorge
#

you as op can type !close to close a help topic, otherwise it will automatically close after one hour of inactivity

good luck with your coding and you can always come back and open new help topics if there is anything more you are wandering about ๐Ÿ™‚

#

yes, a lot of typing (and reading, as it's a lot of code) with java

#

it's quite verbose

#

you'll probably find python much easier to read and write
and you'll probably be more productive in python as well

civic gate
#

thank u again for yalls help <3 really appreciate it

robust gorge
#

but java is much more performant if you need raw performance

civic gate
#

have a good night / day depending on timezone <33

robust gorge
#

otherwise python is mostly find for most tasks

civic gate
#

for this scale all that really matters is ease of writing the code

robust gorge
#

credit where credit is due it's raining outside was the one that actually addressed the issue for this help topic

#

thank you and the same to you ๐Ÿ™‚

civic gate
#

!close!

vapid salmonBOT
#
Did you mean:

!close

civic gate
#

!close

vapid salmonBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.