Commit 43f30aa7 authored by 赵威's avatar 赵威

write date to csv

parent bab61776
...@@ -157,9 +157,12 @@ if __name__ == "__main__": ...@@ -157,9 +157,12 @@ if __name__ == "__main__":
spark = get_spark("test") spark = get_spark("test")
click_df = get_tracate_click_data(spark, get_ndays_before_no_minus(30), get_ndays_before_no_minus(1)) click_df = get_tracate_click_data(spark, get_ndays_before_no_minus(30), get_ndays_before_no_minus(1))
click_df.show(5, False) click_df.show(5, False)
res_dict = get_device_click_tractate_ids_dict(click_df) res_dict = get_device_click_tractate_ids_dict(click_df)
with open(os.path.join(data_dir, "click_tractate_ids.csv"), "w") as f: with open(os.path.join(data_dir, "click_tractate_ids.csv"), "w") as f:
for (k, v) in res_dict: for (k, v) in res_dict.items():
f.write(k + "|" + ",".join(v)) if v:
f.write("{}|{}\n".format(k, ",".join([str(x) for x in v])))
# spark-submit --master yarn --deploy-mode client --queue root.strategy --driver-memory 16g --executor-memory 1g --executor-cores 1 --num-executors 70 --conf spark.default.parallelism=100 --conf spark.storage.memoryFraction=0.5 --conf spark.shuffle.memoryFraction=0.3 --conf spark.locality.wait=0 --jars /srv/apps/tispark-core-2.1-SNAPSHOT-jar-with-dependencies.jar,/srv/apps/spark-connector_2.11-1.9.0-rc2.jar,/srv/apps/mysql-connector-java-5.1.38.jar /srv/apps/strategy_embedding/word_vector/tractate.py # spark-submit --master yarn --deploy-mode client --queue root.strategy --driver-memory 16g --executor-memory 1g --executor-cores 1 --num-executors 70 --conf spark.default.parallelism=100 --conf spark.storage.memoryFraction=0.5 --conf spark.shuffle.memoryFraction=0.3 --conf spark.locality.wait=0 --jars /srv/apps/tispark-core-2.1-SNAPSHOT-jar-with-dependencies.jar,/srv/apps/spark-connector_2.11-1.9.0-rc2.jar,/srv/apps/mysql-connector-java-5.1.38.jar /srv/apps/strategy_embedding/word_vector/tractate.py
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment