`
wang_peng1
  • 浏览: 3942881 次
  • 性别: 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 ...

    HTTPDownloadFileMe.tar.gz_HTTP下载文件_HttpDownloadFile_c http 下载 li

    6. 清理:在完成下载后,别忘了调用`curl_easy_cleanup()`释放资源。 在Linux环境中,我们还需要考虑权限和I/O操作。例如,我们可能需要使用`fopen()`, `fseek()`, 和`fwrite()`等函数来处理文件。同时,确保正确...

    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 ...

    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 ...

    linux下svn命令大全.txt

    清理 (Cleanup) `svncleanup` 命令用于清理SVN的工作副本,移除垃圾文件,修复损坏的元数据。 ### 20. 导入新目录 (Import) `svn import path URL -m "import message"` 命令用于将本地目录导入SVN仓库作为新的...

    BURNINTEST--硬件检测工具

    different Video file and codec. Release 5.3 build 1027 revision 0003 WIN32 release 19 August 2008 - Changed the 2D test to wait for the Video Playback test in order to allow memory allocation for...

    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, ...

    IntelliJ IDEA引入第三方jar包或查看Java源码的时候报decompiled.class file bytecode version:52.0(java 8)错误的解决办法

    你可以在`Build`菜单中选择`Clean Project`,然后`Rebuild Project`。 通过以上步骤,你应该能够解决“decompiled.class file bytecode version:52.0(java 8)”的错误,成功引入第三方jar包并查看源码。记住,保持...

    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...

    系统完整性检测代码.txt

    - **SFC (System File Checker)**:系统文件检查器是Windows操作系统内置的一个命令行工具,用于扫描并修复系统文件损坏或丢失的问题。通过运行`sfc /scannow`命令,可以自动查找并修复被篡改的Windows系统文件。 - ...

Global site tag (gtag.js) - Google Analytics