Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From what I can gather, I believe this will work as a solution, which won't rely on a previously compiled list of files</p> <pre><code>import csv import os, os.path # Replace this with the directory where the household directories are stored. directory = "home" output = open("Output.csv", "wb") csvf = csv.writer(output) headerRow = ["Household", "Lastname", "Firstname", "Account", "Doctype", "Date", "Extension"] csvf.writerow(headerRow) for root, households, files in os.walk(directory): for household in households: for filename in os.listdir(os.path.join(directory, household)): # This will create a record for each filename within the "household" # Then will split the filename out, using the "." as a delimiter # to get the detail csvf.writerow([household] + filename.split(".")) output.flush() output.close() </code></pre> <p>This uses the os library to "walk" the list of households. Then for each "household", it will gather a file listing. It this takes this list, to generate records in a csv file, breaking apart the name of the file, using the period as a delimiter.</p> <p>It makes use of the csv library to generate the output, which will look somewhat like;</p> <pre><code>"Household,LastName,Firstname,Account,Doctype,Date,Extension" </code></pre> <p>If the extension is not needed, then it can be ommited by changing the line:</p> <pre><code>csvf.writerow([household] + filename.split(".")) </code></pre> <p>to</p> <pre><code>csvf.writerow([household] + filename.split(".")[-1]) </code></pre> <p>which tells it to only use up until the last part of the filename, then remove the "Extension" string from headerRow.</p> <p>Hopefully this helps</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload