Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Accessing Files In A Folder
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
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

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Delete Lines that Contain Words - Loop through files in a folder - Write to new files dj99 3 189 Yesterday, 06:34 AM
Last Post: heiner55
  Accessing files in various directories and folders ccuny 2 58 May-08-2019, 12:11 PM
Last Post: ccuny
  Read a folder with a multiple files NewBeie 7 141 May-06-2019, 08:04 AM
Last Post: NewBeie
  folder PyQt5 created during creation exe atlass218 0 71 Apr-26-2019, 06:25 PM
Last Post: atlass218
  Smartsheet api data using python into folder dspy9 0 89 Apr-04-2019, 07:30 PM
Last Post: dspy9
  Including classes from folder issue graham23s 1 126 Apr-03-2019, 07:33 AM
Last Post: Gribouillis
  Scanning files to rename other files in the same folder. msd1391 6 236 Mar-11-2019, 07:19 PM
Last Post: msd1391
  Problems parsing /proc folder anddontyoucomebacknomore 2 168 Mar-06-2019, 09:16 PM
Last Post: DeaD_EyE
  Delete directories in folder is not working after folder is updated asheru93 2 127 Feb-13-2019, 12:37 PM
Last Post: asheru93
  accessing array without commas rjnabil1994 1 131 Feb-10-2019, 06:29 PM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)