Andre Barbosa commited on
Commit
835c2f7
·
1 Parent(s): 551ea2f

add sorting in files before upload

Browse files
Files changed (1) hide show
  1. aes_enem_dataset.py +5 -3
aes_enem_dataset.py CHANGED
@@ -82,7 +82,7 @@ CSV_HEADER = [
82
  class AesEnemDataset(datasets.GeneratorBasedBuilder):
83
  """TODO: Short description of my dataset."""
84
 
85
- VERSION = datasets.Version("0.0.1")
86
 
87
  # You will be able to load one or the other configurations in the following list with
88
  BUILDER_CONFIGS = [
@@ -572,11 +572,12 @@ class HTMLParser:
572
  self.sourceB = f"{filepath}/sourceB/sourceB.csv"
573
  file = self.sourceA if self.sourceA else self.sourceB
574
  file_dir = "/".join((file).split("/")[:-1])
 
575
  with open(file, "w", newline="", encoding="utf8") as final_file:
576
  writer = csv.writer(final_file)
577
  writer.writerow(CSV_HEADER)
578
  sub_folders = [
579
- name for name in os.listdir(file_dir) if not name.endswith(".csv")
580
  ]
581
  essay_id = 0
582
  essay_title = None
@@ -593,7 +594,8 @@ class HTMLParser:
593
  if prompt_folder in PROMPTS_TO_IGNORE:
594
  continue
595
  prompt = os.path.join(file_dir, prompt_folder)
596
- prompt_essays = [name for name in os.listdir(prompt)]
 
597
  essay_year = self._get_essay_year(
598
  self.apply_soup(prompt, "Prompt.html")
599
  )
 
82
  class AesEnemDataset(datasets.GeneratorBasedBuilder):
83
  """TODO: Short description of my dataset."""
84
 
85
+ VERSION = datasets.Version("0.0.2")
86
 
87
  # You will be able to load one or the other configurations in the following list with
88
  BUILDER_CONFIGS = [
 
572
  self.sourceB = f"{filepath}/sourceB/sourceB.csv"
573
  file = self.sourceA if self.sourceA else self.sourceB
574
  file_dir = "/".join((file).split("/")[:-1])
575
+ sorted_files = sorted(os.listdir(file_dir))
576
  with open(file, "w", newline="", encoding="utf8") as final_file:
577
  writer = csv.writer(final_file)
578
  writer.writerow(CSV_HEADER)
579
  sub_folders = [
580
+ name for name in sorted_files if not name.endswith(".csv")
581
  ]
582
  essay_id = 0
583
  essay_title = None
 
594
  if prompt_folder in PROMPTS_TO_IGNORE:
595
  continue
596
  prompt = os.path.join(file_dir, prompt_folder)
597
+ sorted_prompts = sorted(os.listdir(prompt))
598
+ prompt_essays = [name for name in sorted_prompts]
599
  essay_year = self._get_essay_year(
600
  self.apply_soup(prompt, "Prompt.html")
601
  )