Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing Files In A Folder
#1
So I'm working on a program that refers to a lot of data. I store each archive in a separate python file. Each file has a single function: giveArchive() that returns all of its data. So to access any archive, I use:

import fileName
return fileName.giveArchive()

I'm looking to streamline this process a little bit. I want to store all of these files in a folder, and automatically import all of them. I'm trying to just do:

import folderName

which python doesn't seem to have a problem with, but I can't seem to use any of the functions to return archives. How should I go about this?

Using python 3.4.6 btw
Quote
#2
Let me say this is really poor design. You should separate data from logic. Keep data in a database or a simple file (e.g. csv, json, hdf5, etc.) - the choice will depend on type and complexity of data.
What if you need to make changes or add functionality - now you will need to edit every single file.

If you insist on keeping your way - you need to make it a package. Check the documentation
Also a nice post with examples from @snippsat in a similar thread
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Scanning files to rename other files in the same folder. msd1391 6 161 Mar-11-2019, 07:19 PM
Last Post: msd1391
  Problems parsing /proc folder anddontyoucomebacknomore 2 122 Mar-06-2019, 09:16 PM
Last Post: DeaD_EyE
  Delete directories in folder is not working after folder is updated asheru93 2 92 Feb-13-2019, 12:37 PM
Last Post: asheru93
  accessing array without commas rjnabil1994 1 88 Feb-10-2019, 06:29 PM
Last Post: Larz60+
  accessing Sybase (ASE and/or Anywhere) via ODBC... on Linux zatlas1 0 106 Jan-31-2019, 06:48 PM
Last Post: zatlas1
  Accessing Files via Mobaxterm Omer123 1 147 Jan-23-2019, 12:33 AM
Last Post: micseydel
  Executing func() from a different folder ebolisa 2 160 Jan-14-2019, 10:18 AM
Last Post: ebolisa
  python script cant find folder where files are kept Shameendra 2 273 Nov-23-2018, 04:46 PM
Last Post: Shameendra
  Looping through csv files in a folder WhatsupSmiley 3 303 Nov-13-2018, 08:39 PM
Last Post: Larz60+
  Accessing IBM MQ using Python Rajeshs16 6 416 Oct-22-2018, 02:39 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)