static int processCSVStream(final InputStream input, final Token token)
			throws IOException, SQLException {
		final Scanner scanner = new Scanner(input);
		String[] paramNames = null;
		final Map<String, String[]> valuesMap = new HashMap<>();
		int affectedRows = 0;
		try {
			while (scanner.hasNextLine()) {
				final String line = scanner.nextLine();
				if (line.isEmpty())
					continue;
				// Check if comment

				final char c = line.charAt(0);
				if (paramNames == null) {
					// Read header
					String header;
					if (c == '#') {
						header = line.trim();
						if (header.length() <= 1)
							continue;
						header = header.substring(1);
					} else {
						header = line.trim();
					}
					paramNames = splitCsv(header);
					continue;
				} else {
					final String[] values = splitCsv(line);
					valuesMap.clear();
					final int len = Math.min(values.length, paramNames.length);
					if (len == 0)
						continue;
					for (int i = 0; i < len; i++)
						valuesMap
								.put(paramNames[i], new String[] { values[i] });
					// Fill empty values
					for (int i = len; i < paramNames.length; i++)
						valuesMap.put(paramNames[i], new String[] { "" });

					// Print table
					affectedRows += Persistence.appendRow(token, valuesMap);

				}

			}

			return affectedRows;
		} finally {
			scanner.close();
			input.close();
		}
	}