Codota Logo
CSVUtil
Code IndexAdd Codota to your IDE (free)

How to use
CSVUtil
in
org.kitesdk.data.spi.filesystem

Best Java code snippets using org.kitesdk.data.spi.filesystem.CSVUtil (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: apache/nifi

  @Override
  public void process(InputStream in) throws IOException {
    avroSchema.set(CSVUtil
        .inferSchema(
            context.getProperty(RECORD_NAME).evaluateAttributeExpressions(inputFlowFile).getValue(), in, props)
        .toString(context.getProperty(PRETTY_AVRO_OUTPUT).asBoolean()));
  }
});
origin: kite-sdk/kite

                    boolean makeNullable)
 throws IOException {
CSVReader reader = newReader(incoming, props);
 header = newParser(props).parseLine(props.header);
 line = reader.readNext();
 Preconditions.checkNotNull(line, "No content to infer schema");
  if (i < line.length) {
   if (types[i] == null) {
    types[i] = inferFieldType(line[i]);
    if (types[i] != null) {
    .doc("Type inferred from '" + sample(values[i]) + "'")
    .type(schema(types[i], false)).noDefault();
 } else {
  SchemaBuilder.GenericDefault<Schema> defaultBuilder = fieldAssembler.name(fieldName)
    .doc("Type inferred from '" + sample(values[i]) + "'")
    .type(schema(types[i], makeNullable || foundNull));
  if (makeNullable || foundNull) {
   fieldAssembler = defaultBuilder.withDefault(null);
origin: kite-sdk/kite

@Test
public void testSamplePrintableCharactersNotChanged() {
 String upper = "ABCDEFGHIJKLMNOPQRXTUVWXYZ";
 Assert.assertEquals("Upper case letters shouldn't be removed",
   upper, CSVUtil.sample(upper));
 String lower = "abcdefghijklmnopqrstuvwxyz";
 Assert.assertEquals("Lower case letters shouldn't be removed",
   lower, CSVUtil.sample(lower));
 String numbers = "0123456789";
 Assert.assertEquals("Numbers shouldn't be removed",
   numbers, CSVUtil.sample(numbers));
 String punctuation = " _-~+!@#$%^&*(){}[]<>,.?:;`'\"/\\|";
 Assert.assertEquals("Punctuation shouldn't be removed",
   punctuation, CSVUtil.sample(punctuation));
}
origin: org.kitesdk/kite-tools

.inferNullableSchema(
  recordName, open(samplePaths.get(0)), props, required)
.toString(!minimize);
origin: kite-sdk/kite

this.reader = CSVUtil.newReader(incoming, props);
 try {
  header = Lists.newArrayList(
    CSVUtil.newParser(props).parseLine(props.header));
 } catch (IOException e) {
  throw new DatasetIOException(
origin: kite-sdk/kite

public CSVRecordParser(CSVProperties props, Schema schema, Class<E> type,
            @Nullable List<String> header) {
 this.parser = CSVUtil.newParser(props);
 this.builder = new CSVRecordBuilder<E>(
   DataModelUtil.getReaderSchema(type, schema),
   type, getHeader(props, header));
}
origin: kite-sdk/kite

public static Schema inferSchema(String name, InputStream incoming,
                 CSVProperties props,
                 Set<String> requiredFields)
  throws IOException {
 return inferSchemaInternal(name, incoming, props, requiredFields, false);
}
origin: kite-sdk/kite

@Override
public void open() throws IOException {
 this.outgoing = fs.create(path, true /* overwrite */);
 this.writer = CSVUtil.newWriter(outgoing, props);
}
origin: kite-sdk/kite

 @Test
 public void testSampleNull() {
  String nullString = null;
  Assert.assertEquals("Should handle null like String.valueOf",
    String.valueOf(nullString), CSVUtil.sample(nullString));
 }
}
origin: kite-sdk/kite

@Test
public void testSchemaNamespace() throws Exception {
 InputStream stream = new ByteArrayInputStream(csvLines.getBytes("utf8"));
 Schema schema = CSVUtil.inferNullableSchema("com.example.TestRecord",
   stream, new CSVProperties.Builder().hasHeader().build());
 Assert.assertEquals("Should use name", "TestRecord", schema.getName());
 Assert.assertEquals("Should set namespace",
   "com.example", schema.getNamespace());
}
origin: kite-sdk/kite

 public static List<String> getHeader(CSVProperties props,
                    @Nullable List<String> header) {
  if (header != null) {
   return header;
  } else if (props.header != null) {
   try {
    return Lists.newArrayList(
      CSVUtil.newParser(props).parseLine(props.header));
   } catch (IOException e) {
    throw new DatasetIOException(
      "Failed to parse header from properties: " + props.header, e);
   }
  }
  return null;
 }
}
origin: kite-sdk/kite

public static Schema inferNullableSchema(String name, InputStream incoming,
                     CSVProperties props,
                     Set<String> requiredFields)
  throws IOException {
 return inferSchemaInternal(name, incoming, props, requiredFields, true);
}
origin: org.apache.nifi/nifi-kite-processors

  @Override
  public void process(InputStream in) throws IOException {
    avroSchema.set(CSVUtil
        .inferSchema(
            context.getProperty(RECORD_NAME).evaluateAttributeExpressions(inputFlowFile).getValue(), in, props)
        .toString(context.getProperty(PRETTY_AVRO_OUTPUT).asBoolean()));
  }
});
origin: kite-sdk/kite

@Test
public void testUnicodeRemoved() {
 String hasUnicode = "Unicode snowflake: \u2744";
 Assert.assertEquals("Should remove unicode",
   "Unicode snowflake: .", CSVUtil.sample(hasUnicode));
}
origin: kite-sdk/kite

@Test
public void testNullableSchemaInference() throws Exception {
 InputStream stream = new ByteArrayInputStream(csvLines.getBytes("utf8"));
 Schema schema = CSVUtil.inferNullableSchema("TestRecord", stream,
   new CSVProperties.Builder().hasHeader().build(),
   ImmutableSet.of("float"));
origin: kite-sdk/kite

 @Override
 public void run() {
  try {
   CSVUtil.inferSchema("TestRecord",
     new ByteArrayInputStream(csvLines.getBytes("utf8")),
     new CSVProperties.Builder().hasHeader().build(),
     ImmutableSet.of("nullable_string"));
  } catch (IOException e) {
   throw new RuntimeException("Schema inference threw IOException", e);
  }
 }
});
origin: kite-sdk/kite

@Test
public void testSampleTruncated() {
 String longUrl = "https://github.com/kite-sdk/kite/commit/" +
   "bbe3e917875e879ca58b8afe90efa96cdd4691d1";
 Assert.assertEquals("Should truncate long values",
   "https://github.com/kite-sdk/kite/commit/bbe3e91787",
   CSVUtil.sample(longUrl));
}
origin: kite-sdk/kite

@Test
public void testNullableSchemaInferenceWithoutHeader() throws Exception {
 InputStream stream = new ByteArrayInputStream(csvLines.getBytes("utf8"));
 Schema schema = CSVUtil.inferNullableSchema("TestRecord", stream,
   new CSVProperties.Builder().build(),
   ImmutableSet.of("long", "field_1"));
origin: kite-sdk/kite

 @Override
 public void run() {
  try {
   CSVUtil.inferSchema("TestRecord",
     new ByteArrayInputStream(csvLines.getBytes("utf8")),
     new CSVProperties.Builder().hasHeader().build(),
     ImmutableSet.of("nullable_long"));
  } catch (IOException e) {
   throw new RuntimeException("Schema inference threw IOException", e);
  }
 }
});
origin: kite-sdk/kite

@Test
public void testSchemaInferenceMissingExample() throws Exception {
 InputStream stream = new ByteArrayInputStream(
   "\none,two\n34,\n".getBytes("utf8"));
 Schema schema = CSVUtil.inferSchema("TestRecord", stream,
   new CSVProperties.Builder().linesToSkip(1).hasHeader().build());
 Assert.assertNotNull(schema.getField("one"));
 Assert.assertNotNull(schema.getField("two"));
 Assert.assertEquals("Should infer a long",
   schema(Schema.Type.LONG), schema.getField("one").schema());
 Assert.assertEquals("Should default to a string",
   nullable(Schema.Type.STRING), schema.getField("two").schema());
}
org.kitesdk.data.spi.filesystemCSVUtil

Most used methods

  • inferNullableSchema
  • inferSchema
  • sample
  • inferFieldType
  • inferSchemaInternal
  • newParser
  • newReader
  • newWriter
  • schema
    Create a Schema for the given type. If the type is null, the schema will be a nullable String. If is

Popular in Java

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • IsNull (org.hamcrest.core)
    Is the value null?
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now