org.supercsv.cellprocessor.ParseDouble Java Examples

The following examples show how to use org.supercsv.cellprocessor.ParseDouble. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AirportCsvDeserializer.java    From Showcase with Apache License 2.0 6 votes vote down vote up
private CellProcessor[] getCellProcessors() {
    return new CellProcessor[]{
            //@formatter:off
            null,                                  // airport ID
            new Optional(),                        // name
            new Optional(),                        // city
            new Optional(),                        // country
            new Optional(new ParseAirportCode()),  // iataCode
            new Optional(new ParseAirportCode()),  // icaoCode
            new Optional(new ParseDouble()),       // latitude
            new Optional(new ParseDouble()),       // longitude
            null,                                  // altitude
            null,                                  // Timezone
            null,                                  // DST
            null,                                  // Tz database time zone
            null,                                  // Type
            null,                                  // Source
            //@formatter:on
    };

}
 
Example #2
Source File: CacheLoader.java    From geode-demo-application with Apache License 2.0 6 votes vote down vote up
public void loadData() {
	System.out.println("Loading the Data");
	// load the current transactions
	String[] nameMapping = new String[] { "customerId", "productId",
			"quantity", "retailPrice", "id", "markUp", "orderStatus" };
	CellProcessor[] processors = new CellProcessor[] { new NotNull(),// customerId
			new NotNull(),// productId
			new ParseInt(),// quantity
			new ParseDouble(),// retailsPrice
			new NotNull(),// transactionId
			new ParseDouble(),// markUp
			new NotNull() // order status
	};
	loadCurrentTransactions("current_transactions.csv", nameMapping,
			processors);
	System.out
			.println("*************************************************************");
	System.out
			.println("********************PLAYING TRANSACTIONS*********************");
	System.out
			.println("*************************************************************");
	start();
}
 
Example #3
Source File: MarketLogReader.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
private static CellProcessor[] getProcessors() {
	return new CellProcessor[]{
		new ParseDouble(), // price
		new ParseDouble(), // volRemaining
		new ParseInt(), // typeID
		new ParseInt(), // range
		new ParseLong(), // orderID
		new ParseInt(), // volEntered
		new ParseInt(), // minVolume
		new ParseBool(), // bid
		new ParseDate(), // issueDate
		new ParseInt(), // duration
		new ParseLong(), // stationID
		new ParseLong(), // regionID
		new ParseLong(), // solarSystemID
		new ParseInt(), // jumps
		new Optional()
	};
}
 
Example #4
Source File: AbstractCsvParser.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
public void initialise(String[] properties, CellProcessor[] processors)
{
  for (int i = 0; i < getFields().size(); i++) {
    FIELD_TYPE type = getFields().get(i).type;
    properties[i] = getFields().get(i).name;
    if (type == FIELD_TYPE.DOUBLE) {
      processors[i] = new Optional(new ParseDouble());
    } else if (type == FIELD_TYPE.INTEGER) {
      processors[i] = new Optional(new ParseInt());
    } else if (type == FIELD_TYPE.FLOAT) {
      processors[i] = new Optional(new ParseDouble());
    } else if (type == FIELD_TYPE.LONG) {
      processors[i] = new Optional(new ParseLong());
    } else if (type == FIELD_TYPE.SHORT) {
      processors[i] = new Optional(new ParseInt());
    } else if (type == FIELD_TYPE.STRING) {
      processors[i] = new Optional();
    } else if (type == FIELD_TYPE.CHARACTER) {
      processors[i] = new Optional(new ParseChar());
    } else if (type == FIELD_TYPE.BOOLEAN) {
      processors[i] = new Optional(new ParseChar());
    } else if (type == FIELD_TYPE.DATE) {
      processors[i] = new Optional(new ParseDate("dd/MM/yyyy"));
    }
  }

}
 
Example #5
Source File: CellProcessorBuilder.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
/**
 * Get cellprocessor to parse String as Double.
 *
 * @param cellProcessor
 *          next processor in the chain.
 * @return CellProcessor
 */
private static CellProcessor addParseDouble(CellProcessor cellProcessor)
{
  if (cellProcessor == null) {
    return new ParseDouble();
  }
  return new ParseDouble((DoubleCellProcessor)cellProcessor);
}
 
Example #6
Source File: CacheLoader.java    From geode-demo-application with Apache License 2.0 4 votes vote down vote up
/**
 * Call this to load the Data, it uses the CSV files in its classpath
 */
public void loadData() {
	
	startTime = new Date().getTime();
	
	//load the customers
	String[] nameMapping = new String[]{"city","birthday","id","name", "emailAddress"};
	CellProcessor[] processors = new CellProcessor[] { 
       		new NotNull(), //city
       		new ParseDate("dd-MM-yyyy"), //birthday
               new NotNull(), //id
               new NotNull(), //name
               new NotNull() //email
       };
       loadCustomers("customer.csv",nameMapping,processors);
       
       //load the products
       nameMapping = new String[]{"stockOnHand","wholeSalePrice","brand","type", "color", "size", "gender", "id"};
       processors = new CellProcessor[] { 
       		new ParseInt(),//stockOnHand
       		new ParseDouble(),//wholeSalePrice
       		new NotNull(),//brand
       		new NotNull(),//type
       		new NotNull(),//color
       		new ParseDouble(),//size
       		new NotNull(),//gender
               new NotNull()//productId
       };
       loadProducts("products.csv",nameMapping,processors);
       
       //load the historic transactions - these are just randomly generated and do not respect stock quantity
       nameMapping = new String[]{"customerId","transactionDate","productId","quantity", "retailPrice", "id", "markUp", "orderStatus"};
       processors = new CellProcessor[] { 
       		new NotNull(),//customerId
       		new ParseDate("dd-MM-yyyy"),//transactionDate
       		new NotNull(),//productId
       		new ParseInt(),//quantity
       		new ParseDouble(),//retailsPrice
       		new NotNull(),//transactionId
       		new ParseDouble(),//markUp
       		new NotNull()//order status
       };
       loadTransactions("transactions.csv",nameMapping,processors);
       
       //load the mark ups
       nameMapping = new String[]{"id", "rate","levelName","qualifyingTransactionCountFloor","qualifyingTransactionCountCeiling"};
       processors = new CellProcessor[] {
       		new NotNull(),//id
       		new ParseDouble(),//rate
       		new NotNull(),//levelName
       		new ParseInt(),//qualifyingTransactionCountFloor
       		new ParseInt()//qualifyingTransactionCountCeiling
       };
       loadMarkUps("markUps.csv",nameMapping,processors);
       
       //clean out the alerts
       for (Alert alert : alertRepository.findAll()) {
       	alertRepository.delete(alert);
       }
       long endTime = new Date().getTime();
	long timeToLoad = endTime - startTime;
	activityLog.add("Total Loading Time: " + timeToLoad/1000 + " seconds");
       closeBeanReader();
	writeOutLogs();
}