`
wang_peng1
  • 浏览: 3900925 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

download and clean file

 
阅读更多
import argparse
import os
import sys

from six.moves import urllib
import tensorflow as tf

DATA_URL = 'https://archive.ics.uci.edu/ml/machine-learning-databases/adult'
TRAINING_FILE = 'adult.data'
TRAINING_URL = '%s/%s' % (DATA_URL, TRAINING_FILE)
EVAL_FILE = 'adult.test'
EVAL_URL = '%s/%s' % (DATA_URL, EVAL_FILE)

parser = argparse.ArgumentParser()

parser.add_argument(
    '--data_dir', type=str, default='/tmp/census_data',
    help='Directory to download census data')


def _download_and_clean_file(filename, url):
  """Downloads data from url, and makes changes to match the CSV format."""
  temp_file, _ = urllib.request.urlretrieve(url)
  print("temp_file",temp_file)
  with tf.gfile.Open(temp_file, 'r') as temp_eval_file:
    with tf.gfile.Open(filename, 'w') as eval_file:
      for line in temp_eval_file:
        line = line.strip()
        line = line.replace(', ', ',')
        if not line or ',' not in line:
          continue
        if line[-1] == '.':
          line = line[:-1]
        line += '\n'
        eval_file.write(line)
  tf.gfile.Remove(temp_file)


def main(unused_argv):
  if not tf.gfile.Exists(FLAGS.data_dir):
    tf.gfile.MkDir(FLAGS.data_dir)

  training_file_path = os.path.join(FLAGS.data_dir, TRAINING_FILE)
  _download_and_clean_file(training_file_path, TRAINING_URL)

  eval_file_path = os.path.join(FLAGS.data_dir, EVAL_FILE)
  _download_and_clean_file(eval_file_path, EVAL_URL)
  print("eval_file_path",eval_file_path)


if __name__ == '__main__':
  FLAGS, unparsed = parser.parse_known_args()
  tf.app.run(argv=[sys.argv[0]] + unparsed)

 

分享到:
评论

相关推荐

    Spring Boot Auth with JWT TOKEN and ROLES

    Clean MVN ( clean the target | download necessary dependencies | compile run the unit tests ) and Create a JAR file and make that aviable in the project directory $ mvn clean install = JAR ...

    UE(官方下载)

    A question we often see is "I have a lot of blank lines in my file and I don't want to go through and manually delete them. Is there an easier way to do this?" The answer is: yes! Configure FTP Set up...

    WinZip Pro 18.5 Build 11111 (x86-x64)+SerialKey

    With the new WinZip 18, you can quickly and securely zip and unzip files to conserve storage space, speed up e-mail transmission, and reduce download times. State-of-the-art file compression, strong ...

    SWT例子文件

    1.Download and install the Eclipse Example Plug-ins. The Eclipse Example Plug-ins are available on the same download page as the Eclipse SDK. Look for the section titled Example Plug-ins. You can ...

    spring-boot-file-upload-download-rest-api

    cd spring-boot-file-upload-download-rest-api-example mvn spring-boot:run 就是这样! 可以从http://localhost:8080访问该应用程序。 您也可以以jar的形式打包应用程序,然后像下面那样运行jar文件- mvn clean...

    spring-boot-file-upload-download-rest-api-example:Spring Boot文件上传下载Rest API示例

    cd spring-boot-file-upload-download-rest-api-example mvn spring-boot:run 而已! 可以从http://localhost:8080访问该应用程序。 您也可以以jar的形式打包应用程序,然后像这样运行jar文件- mvn clean package...

    P.A.T.C.H. - Ultimate Patching System [FULL]

    An all-in-one, smart and clean solution! It can generate very small patches thanks to its included file binary diffing algorithm. What does it mean? It means that if you change only 5 bytes in your ...

    jenkins credentials-plugin1.11.hpi

    download from github,and have build it by: Run mvn clean package to create the plugin .hpi file. To install: 1. copy the resulting ./target/credentials.hpi file to the $JENKINS_HOME/plugins ...

    移动代理源代码

    Change the setupMUM batch file so that the absolute paths to the Ant home and JSDK are correct. Now you have finished the installation and you can launch the system! First launch exec the setupMUM ...

    Pro Python 3, 3rd 英文版

    Pro Python 3, Third Edition gives you the tools to write clean, innovative code. It starts with a review of some core Python principles, which are illustrated by various concepts and examples later in...

    BobBuilder_app

    Two mode of operation Flush immediate and Deferred ( the latter being faster at the expense of the risk of non-clean shutdown data loss). Enumerate the index is supported. Enumerate the Storage file ...

    drupal 6.12

    6. REVIEW FILE SYSTEM STORAGE SETTINGS AND FILE PERMISSIONS The files directory created in step 4 is the default file system path used to store all uploaded files, as well as some temporary files ...

    cutEditor -最好用的在线编辑器

    With online image editor, you can now edit image file with no image editing software to download or install! Easy drag and drop familiar interface. Resize, change dimensions, scale, crop, add text, ...

    Ftp Server 源代码

    TYPSoft FTP Server is a fast and easy ftp server with support toStandard FTP Command, Clean interface, Virtual File Systemarchitecture, ability to resume Download and Upload, IP Restriction, Login/...

    Data Preprocessing

    Before Data Analysis, ...Download the file directly and use it by no matter what programming language including python or java. Enjoy yourself and Become more and more experienced !!!

    apktool documentation

    apks are nothing more than a zip file containing resources and compiled java. If you were to simply unzip an apk like so, you would be left with files such as classes.dex and resources.arsc. $ unzip...

    ak2新版内核AKAIO1.5

    + New Super Mario Brothers Minigames on AK2: If they don't work, set Download Play to "Disabled" and boot in non-DMA mode (hold down A while loading) + Misc bug fixes (Too many to list). AK-AIO 1.2 +...

    coursera-getting-cleaning-data:在 Coursera 上获取清洁数据课程的最终项目

    可用的文件有: - `README.md` : this file - `CodeBook.MD` : a code book that describes the variables, the data, and any transformations or work performed to clean up the data - `run_analysis.R` : the ...

    DXperience Universal + IDETools 10.2.6 SetUp + Crack

    so what this smart addin is replace to your output directory the files needed (actually 1 file) to be ready for deploy to a "clean" pc without devexpress automatically every time you BUILD your ...

    DownTool.rar

    FILE *outfile; char *url = haddr; char filename[MAX_PATH] = {0}; sprintf(filename,"%sdownload\\%s",GetCurExePath(),strFile); curl = curl_easy_init(); if(curl) { outfile = ::fopen((char *)...

Global site tag (gtag.js) - Google Analytics