当前位置: 首页>>代码示例>>Java>>正文


Java Frame.toCSV方法代码示例

本文整理汇总了Java中water.fvec.Frame.toCSV方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.toCSV方法的具体用法?Java Frame.toCSV怎么用?Java Frame.toCSV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在water.fvec.Frame的用法示例。


在下文中一共展示了Frame.toCSV方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fetch

import water.fvec.Frame; //导入方法依赖的package包/类
@SuppressWarnings("unused") // called through reflection by RequestServer
public DownloadDataV3 fetch(int version, DownloadDataV3 server) {

  if (DKV.get(server.frame_id.key()) == null) throw new H2OKeyNotFoundArgumentException("key", server.frame_id.key());
  Frame value = server.frame_id.key().get();
  InputStream is = value.toCSV(true, server.hex_string);
  java.util.Scanner scanner = new java.util.Scanner(is).useDelimiter("\\A");
  server.csv = (scanner.hasNext() ? scanner.next() : "");

  // Clean up Key name back to something resembling a file system name.  Hope
  // the user's browser actually asks for what to do with the suggested
  // filename.  Without this code, my FireFox would claim something silly
  // like "no helper app installed", then fail the download.
  String s = server.frame_id.toString();
  int x = s.length()-1;
  boolean dot=false;
  for( ; x >= 0; x-- )
    if( !Character.isLetterOrDigit(s.charAt(x)) && s.charAt(x)!='_' )
      if( s.charAt(x)=='.' && !dot ) dot=true;
      else break;
  String suggested_fname = s.substring(x+1).replace(".hex", ".csv");
  if( !suggested_fname.endsWith(".csv") )
    suggested_fname = suggested_fname+".csv";
  server.filename = suggested_fname;
  return server;
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:27,代码来源:DownloadDataHandler.java

示例2: doGet

import water.fvec.Frame; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request,
                     HttpServletResponse response) throws IOException, ServletException {
  String uri = getDecodedUri(request);
  try {
    boolean use_hex = false;
    String f_name = request.getParameter("frame_id");
    String hex_string = request.getParameter("hex_string");
    if (f_name == null) {
      throw new RuntimeException("Cannot find value for parameter \'frame_id\'");
    }
    if (hex_string != null && hex_string.toLowerCase().equals("true")) {
      use_hex = true;
    }
    
    Frame dataset = DKV.getGet(f_name);
    // TODO: Find a way to determing the hex_string parameter. It should not always be false
    InputStream is = dataset.toCSV(true, use_hex);
    response.setContentType("application/octet-stream");
    // Clean up the file name
    int x = f_name.length()-1;
    boolean dot=false;
    for( ; x >= 0; x-- )
      if( !Character.isLetterOrDigit(f_name.charAt(x)) && f_name.charAt(x)!='_' )
        if( f_name.charAt(x)=='.' && !dot ) dot=true;
        else break;
    String suggested_fname = f_name.substring(x+1).replace(".hex", ".csv");
    if( !suggested_fname.endsWith(".csv") )
      suggested_fname = suggested_fname+".csv";
    f_name = suggested_fname;
    response.addHeader("Content-Disposition", "attachment; filename=" + f_name);
    setResponseStatus(response, HttpServletResponse.SC_OK);
    OutputStream os = response.getOutputStream();
    water.util.FileUtils.copyStream(is, os, 2048);
  }
  catch (Exception e) {
    sendErrorResponse(response, e, uri);
  }
  finally {
    logRequest("GET", request, response);
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:43,代码来源:JettyHTTPD.java


注:本文中的water.fvec.Frame.toCSV方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。