Example #1
0
        public void DataTableCSV()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

            var dt  = new UXFDataTable("null", "float", "comma", "period");
            var row = new UXFDataRow();

            row.Add(("null", null));
            row.Add(("float", 3.14f));
            row.Add(("comma", "i have, commas"));
            row.Add(("period", "i have, periods"));

            dt.AddCompleteRow(row);

            string expected = string.Join("\n", new string[] { "null,float,comma,period", "null,3.14,i have_ commas,i have_ periods" });
            string csv      = string.Join("\n", dt.GetCSVLines());

            Assert.AreEqual(expected, csv);
        }
        public override string HandleDataTable(UXFDataTable table, string experiment, string ppid, int sessionNum, string dataName, UXFDataType dataType, int optionalTrialNum = 0)
        {
            if (dataType != UXFDataType.TrialResults && trialResultsOnly)
            {
                return("NA");
            }
            if (dataType.GetDataLevel() == UXFDataLevel.PerTrial)
            {
                dataName = string.Format("{0}_T{1:000}", dataName, optionalTrialNum);
            }

            string[] lines   = table.GetCSVLines();
            string   fname   = string.Format("{0}.csv", dataName);
            string   content = string.Join("\n", lines);

            // if trial results, push to top of list for convenience
            CreateNewItem(content, fname, pushToTop: dataType == UXFDataType.TrialResults);

            return(fname);
        }
Example #3
0
        public override string HandleDataTable(UXFDataTable table, string experiment, string ppid, int sessionNum, string dataName, UXFDataType dataType, int optionalTrialNum = 0)
        {
            Debug.LogFormat("Handling a data table for session: {0}, {1}, {2}", experiment, ppid, sessionNum);
            Debug.LogFormat("The data name is: {0}, and the type is: ", dataName, dataType);

            if (dataType.GetDataLevel() == UXFDataLevel.PerTrial)
            {
                Debug.LogFormat("Data is per-trial, trial number is {0}.", optionalTrialNum);
            }
            else
            {
                Debug.Log("Data is per-session.");
            }

            // get data as text
            string[] lines = table.GetCSVLines();
            string   text  = string.Join("\n", lines);

            // here we "write" our data, you could upload to database, or do whatever.
            Debug.Log(text);

            // return a string representing the location of the data. Will be stored in the trial_results output.
            return("Data printed to console.");
        }