-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from Crinibus/dev
Version v1.1
- Loading branch information
Showing
11 changed files
with
169 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from scraper.filemanager import Filemanager | ||
|
||
|
||
def clean_data() -> None: | ||
print("Cleaning data...") | ||
records_data = Filemanager.get_record_data() | ||
|
||
for category_info in records_data.values(): | ||
for product_info in category_info.values(): | ||
for website_info in product_info.values(): | ||
datapoints = website_info["datapoints"] | ||
|
||
new_datapoints = [] | ||
|
||
for index, datapoint in enumerate(datapoints): | ||
if index in (0, len(datapoints) - 1): | ||
new_datapoints.append(datapoint) | ||
continue | ||
|
||
previous_datapoint = datapoints[index - 1] | ||
next_datapoint = datapoints[index + 1] | ||
|
||
# Skip unnecessary datapoints | ||
if ( | ||
datapoint["price"] == previous_datapoint["price"] | ||
and datapoint["price"] == next_datapoint["price"] | ||
): | ||
continue | ||
|
||
new_datapoints.append(datapoint) | ||
|
||
website_info["datapoints"] = new_datapoints | ||
|
||
Filemanager.save_record_data(records_data) | ||
print("Done cleaning data") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.