public void LoadGoogleSheetsPalette(string url) { //Download CSV from Public Google Sheets string csvurl = ""; if (url.Substring(url.LastIndexOf("/")).Length < 25) { csvurl = url.Substring(0, url.LastIndexOf("/")) + "/export?format=csv&gid=0"; } else { csvurl = url + "/export?format=csv&gid=0"; } Debug.Log(csvurl); WWW data = new WWW(csvurl); while (!data.isDone) { } //Load CSV string[][] table = CsvParser2.Parse(data.text); string title = GetGoogleSheetTitle(url); LoadPalette(table, title); }
public static string Generate(string csvText, string className) { if (string.IsNullOrEmpty(csvText)) { return(null); } string[][] grid = CsvParser2.Parse(csvText); if (grid.Length < 1) { return(null); } string rowMemberCode = ""; string rowReadCode = ""; string findCode = ""; for (int i = 0; i < grid[0].Length; i++) { rowMemberCode += string.Format("\t\tpublic string {0};\n", grid[0][i]); rowReadCode += string.Format("\t\t\trow.{0} = grid[i][{1}];\n", grid[0][i], i); findCode += findCodeTemplate.Replace("$COLUMN", grid[0][i]); } string code = codeTemplate; code = code.Replace("$CLASS", className); code = code.Replace("$ROW_MEMBER_CODE", rowMemberCode); code = code.Replace("$ROW_READ_CODE", rowReadCode); code = code.Replace("$FIND_CODE", findCode); return(code); }
void OnGUI() { TextAsset newCsv = EditorGUILayout.ObjectField("CSV", csv, typeof(TextAsset), false) as TextAsset; if (newCsv != csv) { csv = newCsv; arr = CsvParser2.Parse(csv.text); } if (GUILayout.Button("Refresh") && csv != null) { arr = CsvParser2.Parse(csv.text); } if (csv == null) { return; } if (arr == null) { arr = CsvParser2.Parse(csv.text); } for (int i = 0; i < arr.Length; i++) { EditorGUILayout.BeginHorizontal(); for (int j = 0; j < arr[i].Length; j++) { EditorGUILayout.TextField(arr[i][j]); } EditorGUILayout.EndHorizontal(); } }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.id = grid[i][0]; row.health1 = grid[i][1]; row.health2 = grid[i][2]; row.maxspd = grid[i][3]; row.accel = grid[i][4]; row.jumpheight = grid[i][5]; row.jumpforce = grid[i][6]; row.atk1 = grid[i][7]; row.atk2 = grid[i][8]; row.atkrate1 = grid[i][9]; row.atkrate2 = grid[i][10]; row.numlives = grid[i][11]; row.playerno = grid[i][12]; row.mobno = grid[i][13]; row.addno = grid[i][14]; row.bossno = grid[i][15]; rowList.Add(row); } isLoaded = true; }
/// <summary> /// Loads stage from a csv file. /// </summary> /// <param name="filename">File to be loaded.</param> /// <returns></returns> public static StageModel LoadStageFromFile(string filename) { var path = _stagesPath + filename; if (!File.Exists(path)) { throw new FileNotFoundException($"Stage file '{path}' not found!"); } var data = FileManager.ReadAllLines(path); CleanData(ref data, path); var stageHeader = $"{data[0]}\n{data[1]}"; var grid = CsvParser2.Parse(stageHeader); var stageInfo = new StageModel { //header Id = int.Parse(grid[1][0]), Phase = int.Parse(grid[1][1]), Level = int.Parse(grid[1][2]), ObjectSpeedFactor = Parsers.Float(grid[1][3]), HeightIncrement = Parsers.Float(grid[1][4]), HeightUpThreshold = int.Parse(grid[1][5]), HeightDownThreshold = int.Parse(grid[1][6]), SizeIncrement = Parsers.Float(grid[1][7]), SizeUpThreshold = int.Parse(grid[1][8]), SizeDownThreshold = int.Parse(grid[1][9]), Loops = int.Parse(grid[1][10]), }; stageInfo.Loops = stageInfo.Loops == 0 ? 1 : stageInfo.Loops; var template = "ObjectType;DifficultyFactor;PositionYFactor;PositionXSpacing"; // Read each line from the file to get objects to spawn for (int i = 2; i < data.Length; i++) { if (data[i].StartsWith("%") || string.IsNullOrEmpty(data[i])) { continue; } var modelGrid = CsvParser2.Parse($"{template}\n{data[i]}"); var model = new ObjectModel { Id = i, Type = (StageObjectType)Enum.Parse(typeof(StageObjectType), (modelGrid[1][0])), DifficultyFactor = Parsers.Float(modelGrid[1][1]), PositionYFactor = Parsers.Float(modelGrid[1][2]), PositionXSpacing = Parsers.Float(modelGrid[1][3]), }; stageInfo.ObjectModels.Add(model); } return(stageInfo); }
public static string Generate(string csvText, string className) { if (string.IsNullOrEmpty(csvText)) { return(null); } var grid = CsvParser2.Parse(csvText); if (grid.Length < 1) { return(null); } var rowMemberCode = ""; var rowReadCode = ""; var findCode = ""; for (var i = 0; i < grid[0].Length; i++) { rowMemberCode += $"\t\tpublic string {grid[0][i]};\n"; rowReadCode += $"\t\t\trow.{grid[0][i]} = grid[i][{i}];\n"; findCode += findCodeTemplate.Replace("$COLUMN", grid[0][i]); } var code = codeTemplate; code = code.Replace("$CLASS", className); code = code.Replace("$ROW_MEMBER_CODE", rowMemberCode); code = code.Replace("$ROW_READ_CODE", rowReadCode); code = code.Replace("$FIND_CODE", findCode); return(code); }
private void OnGUI() { var newCsv = EditorGUILayout.ObjectField("CSV", csv, typeof(TextAsset), false) as TextAsset; if (newCsv != csv) { csv = newCsv; arr = CsvParser2.Parse(csv.text); } if (GUILayout.Button("Refresh") && csv != null) { arr = CsvParser2.Parse(csv.text); } if (csv == null) { return; } if (arr == null) { arr = CsvParser2.Parse(csv.text); } foreach (var t in arr) { EditorGUILayout.BeginHorizontal(); foreach (var t1 in t) { EditorGUILayout.TextField(t1); } EditorGUILayout.EndHorizontal(); } }
private void ImportRows(DatablockDetectionInfo datablockDetectionInfo) { using (TextReader reader = File.OpenText(csvFilePath)) { var parser = new CsvParser2(); parser.TrimTrailingEmptyLines = true; string[][] parsed = parser.Parse(reader); for (int i = 1; i < parsed.GetLength(0); i++) { string[] row = parsed[i]; string datablockName = row[nameIndex]; Datablock datablock = GetNamedDatablock(datablockDetectionInfo, datablockName); for (int index = 0; index < parsed[i].Length; index++) { if (index == headers.Count) { break; } string fieldValue = parsed[i][index]; string fieldName = headers[index]; ProcessRawField(datablockDetectionInfo, fieldName, datablock, fieldValue); } } Debug.Log("Imported " + (parsed.GetLength(0) - 1) + " datablocks."); } }
public void Load(string text) { rowList.Clear(); string[][] grid = CsvParser2.Parse(text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.type = grid[i][0]; row.difficulty = grid[i][1]; row.english = grid[i][2]; row.german = grid[i][3]; row.french = grid[i][4]; row.dutch = grid[i][5]; rowList.Add(row); } foreach (Row row in rowList) { if (row.difficulty == "easy") { wordsEasy.Add(row); } if (row.difficulty == "medium") { wordsMedium.Add(row); } if (row.difficulty == "hard") { wordsHard.Add(row); } } isLoaded = true; }
public void Load() { rowList.Clear(); string[][] grid = CsvParser2.Parse(file.text); for (int i = 1; i < grid.Length; i++) { int j = 0; MyPlayerEvent row = new MyPlayerEvent(); try { j = 0; row.eventtype = EnumUtil.EnumFromString <PlayerEvent>(grid[i][j++], PlayerEvent.Null); row.attribute_1 = grid[i][j++]; row.attribute_2 = grid[i][j++]; row.metric_1 = (grid[i][j].Equals(""))? 0 : float.Parse(grid[i][j]); j++; row.metric_2 = (grid[i][j].Equals("")) ? 0 : float.Parse(grid[i][j]); j++; row.wave_time = (grid[i][j].Equals("")) ? 0 : float.Parse(grid[i][j]); j++; row.eventtime = DateTime.Parse(grid[i][j]); } catch (Exception e) { Debug.Log("Could not parse " + String.Join(" | ", grid[i]) + " j " + j + " " + e.Message + "\n"); } rowList.Add(row); } rowList.Sort(); isLoaded = true; }
private void ImportRows(DatablockDetectionInfo datablockDetectionInfo) { using (TextReader reader = File.OpenText(csvFilePath)) { var parser = new CsvParser2(); parser.TrimTrailingEmptyLines = true; string[][] parsed = parser.Parse(reader); for (int i = 1; i < parsed.GetLength(0); i++) { string[] row = parsed[i]; string datablockName = row[nameIndex]; Datablock datablock = GetNamedDatablock(datablockDetectionInfo, datablockName); for (int index = 0; index < parsed[i].Length; index++) { if (index == headers.Count) break; string fieldValue = parsed[i][index]; string fieldName = headers[index]; ProcessRawField(datablockDetectionInfo, fieldName, datablock, fieldValue); } } Debug.Log("Imported " + (parsed.GetLength(0) - 1) + " datablocks."); } }
/// <summary> /// Loads all the information /// </summary> /// <param name="csv"></param> public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.Player = grid[i][0]; row.TotalPitchesThrown = grid[i][1]; row.TotalFastballs = grid[i][2]; row.TotalCurveballs = grid[i][3]; row.TotalChangeups = grid[i][4]; row.TotalSliders = grid[i][5]; row.TotalSinkers = grid[i][6]; row.FB_R = grid[i][7]; row.FB_L = grid[i][8]; row.CV_R = grid[i][9]; row.CV_L = grid[i][10]; row.CH_R = grid[i][11]; row.CH_L = grid[i][12]; row.SL_R = grid[i][13]; row.SL_L = grid[i][14]; row.SI_R = grid[i][15]; row.SI_L = grid[i][16]; rowList.Add(row); } isLoaded = true; }
IEnumerator LoadData(string url) { loadDataResult = new List <List <string> >(); using (UnityWebRequest req = UnityWebRequest.Get(url)) { req.timeout = 5; yield return(req.SendWebRequest()); if (req.isNetworkError || req.isHttpError) { Debug.Log(req.error); errorOnWebRequest = true; } else { foreach (var line in CsvParser2.Parse(req.downloadHandler.text)) { loadDataResult.Add(line.ToList()); } } } yield return(null); }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.Phrase = grid[i][0]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.id = grid[i][0]; row.hip = grid[i][1]; row.hd = grid[i][2]; row.hr = grid[i][3]; row.gl = grid[i][4]; row.bf = grid[i][5]; row.proper = grid[i][6]; row.ra = grid[i][7]; row.dec = grid[i][8]; row.dist = grid[i][9]; row.pmra = grid[i][10]; row.pmdec = grid[i][11]; row.rv = grid[i][12]; row.mag = grid[i][13]; row.absmag = grid[i][14]; row.spect = grid[i][15]; row.ci = grid[i][16]; row.x = grid[i][17]; row.y = grid[i][18]; row.z = grid[i][19]; row.vx = grid[i][20]; row.vy = grid[i][21]; row.vz = grid[i][22]; row.rarad = grid[i][23]; row.decrad = grid[i][24]; row.pmrarad = grid[i][25]; row.pmdecrad = grid[i][26]; row.bayer = grid[i][27]; row.flam = grid[i][28]; row.con = grid[i][29]; row.comp = grid[i][30]; row.comp_primary = grid[i][31]; row._base = grid[i][32]; row.lum = grid[i][33]; row.var = grid[i][34]; row.var_min = grid[i][35]; row.var_max = grid[i][36]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.Level = grid[i][0]; row.MaxExp = grid[i][1]; row.MissileCount = grid[i][2]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Drug row = new Drug(); row.ID = int.Parse(grid[i][0]); row.DrugName = grid[i][1]; if (grid[i][2] != "") { row.Concentration = float.Parse(grid[i][2]); } else { row.Concentration = null; } row.ConcentrationUnit = grid[i][3]; row.AdditionalText = grid[i][4]; row.Unit = grid[i][5]; row.IsSyringe = (grid[i][6] == "1"); row.FullLabelText = row.DrugName + " " + row.Concentration + " " + row.ConcentrationUnit + " " + row.AdditionalText + " " + row.Unit; if (grid[i][7] != "") { row.PrimaryColor = new Color32(byte.Parse(grid[i][7]), byte.Parse(grid[i][8]), byte.Parse(grid[i][9]), 255); } else { row.PrimaryColor = new Color32(255, 255, 255, 255); } if (grid[i][10] != "") { row.SecondaryColor = new Color32(byte.Parse(grid[i][10]), byte.Parse(grid[i][11]), byte.Parse(grid[i][12]), 255); } else { row.SecondaryColor = row.PrimaryColor; } rowList.Add(row); } Loaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.FindItem = new List <string>(grid[i][2].Split(","[0])); row.ID = grid[i][0]; row.MapName = grid[i][1]; row.Reward = grid[i][3]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.IDMini = grid[i][0]; row.Mapname = grid[i][1]; row.IDItem = grid[i][2]; row.Detail = grid[i][3]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.ID = grid[i][0]; row.Name = grid[i][1]; row.MeshPath = grid[i][2]; row.ImagePath = grid[i][3]; rowList.Add(row); } isLoaded = true; }
public void Load(string text) { rowList.Clear(); string[][] grid = CsvParser2.Parse(text); for (int i = 0; i < grid.Length; i++) { Row row = new Row(); row.key = grid[i][0]; row.english = grid[i][1]; row.german = grid[i][2]; row.french = grid[i][3]; row.dutch = grid[i][4]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.WardNumber = grid[i][0]; row.HouseholdNum = grid[i][1]; row.UniverstiyDegree = grid[i][2]; row.Employed = grid[i][3]; rowList.Add(row); } isLoaded = true; }
public void Load(string text) { rowList.Clear(); string[][] grid = CsvParser2.Parse(text); for (int i = 0; i < grid.Length; i++) { Row row = new Row(); row.startingbudget = grid[i][0]; row.minplayers = grid[i][1]; row.gameendtime = grid[i][2]; row.utopiarate = grid[i][3]; row.mayorlevel = grid[i][4]; row.minigametime = grid[i][5]; rowList.Add(row); } isLoaded = true; }
public void Load(string text) { rowList.Clear(); string[][] grid = CsvParser2.Parse(text); for (int i = 0; i < grid.Length; i++) { Row row = new Row(); row.rank = grid[i][0]; row.unlock = grid[i][1]; row.influencegoal = grid[i][2]; row.environmentplayer = grid[i][3]; row.socialplayer = grid[i][4]; row.financeplayer = grid[i][5]; rowList.Add(row); } isLoaded = true; }
public List <Row> Load(TextAsset csv) { List <Row> rowList = new List <Row>(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.time = int.Parse(grid[i][0]); row.danmakuType = int.Parse(grid[i][1]); row.danmakuCount = int.Parse(grid[i][2]); rowList.Add(row); } return(rowList); }
private void LoadGlobals() { var data = FileManager.ReadCsv(Application.streamingAssetsPath + @"/Constants.csv"); var grid = CsvParser2.Parse(data); CapacityMultiplier = Parsers.Float(grid[1][0]); LevelUnlockScoreThreshold = Mathf.Clamp(Parsers.Float(grid[1][1]), 0.5f, 1f); Pitaco.AirViscosity = Parsers.Float(grid[1][2]); Pitaco.Lenght = Parsers.Float(grid[1][3]); Pitaco.Radius = Parsers.Float(grid[1][4]); Mano.AirViscosity = Parsers.Float(grid[1][5]); Mano.Lenght = Parsers.Float(grid[1][6]); Mano.Radius = Parsers.Float(grid[1][7]); Cinta.AirViscosity = Parsers.Float(grid[1][8]); Cinta.Lenght = Parsers.Float(grid[1][9]); Cinta.Radius = Parsers.Float(grid[1][10]); }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.name = grid[i][0]; row.greeting = grid[i][1]; row.timeFactor = grid[i][2]; row.combo = grid[i][3]; row.points = grid[i][4]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.Date = grid[i][0]; row.Time = grid[i][1]; row.User = grid[i][2]; row.Pages = grid[i][3]; row.Title = grid[i][4]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.Avenue = grid[i][0]; row.num = grid[i][1]; row.Building = grid[i][2]; row.Floors = grid[i][3]; row.Tenant = grid[i][4]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.Year = grid[i][0]; row.Make = grid[i][1]; row.Model = grid[i][2]; row.Description = grid[i][3]; row.Price = grid[i][4]; rowList.Add(row); } isLoaded = true; }
public void Load(TextAsset csv) { rowList.Clear(); string[][] grid = CsvParser2.Parse(csv.text); for (int i = 1; i < grid.Length; i++) { Row row = new Row(); row.lieu = grid[i][0]; row.lng = grid[i][2]; row.lat = grid[i][1]; row.description = grid[i][3]; row.fichier = grid[i][4]; rowList.Add(row); } isLoaded = true; }