This is the code that you could use to convert the csv into a 3D polyline:
def main():
    import csv
    import arcpy
    # input csv
    csv_path = r"C:\Forum\3Dpnts_3Dlines\SampleData_well.csv"
    fld_x = 'bh_long'
    fld_y = 'bh_lat'
    fld_z = 'Z'
    fld_order = 'measdpth'
    fld_lineid = 'api_wellno'
    # settings
    sr = arcpy.SpatialReference(4326) # WGS_1984
    arcpy.env.overwriteOutput = True
    feetinmeter = 0.3048
    # output featureclass (could also point to fc in fgdb)
    fc = r"C:\Forum\3Dpnts_3Dlines\shp\test01.shp"
    lineids = []
    dct = {}
    # read csv
    with open(csv_path, 'rb') as f:
        reader = csv.reader(f)
        cnt = 0
        for row in reader:
            cnt += 1
            if cnt == 1:
                # header
                header = row
            else:
                # read fields from data
                lineid = row[header.index(fld_lineid)]
                x = float(row[header.index(fld_x)])
                y = float(row[header.index(fld_y)])
                z = float(row[header.index(fld_z)]) * feetinmeter
                # create point object with XYZ
                pnt = arcpy.Point(x, y, z)
                # read order and create string to sort on (lineid + order)
                order = row[header.index(fld_order)]
                srt =  "{0}_{1}".format("%04d" % (int(lineid),),
                      "{0}".format(round(float(order), 1)).zfill(8))
                # create nested dictionary with points per line
                if lineid in dct:
                    dct[lineid][srt] = pnt
                else:
                    dct[lineid] = {}
                    dct[lineid][srt] = pnt
    # create polylines
    lst_polylines = []
    for lineid, dct2 in dct.items():
        lst_pnt = []
        for srt, pnt in sorted(dct2.items()):
            lst_pnt.append(pnt)
        polyline = arcpy.Polyline(arcpy.Array(lst_pnt), sr, True, False)
        lst_polylines.append(polyline)
    # write polylines to output featureclass
    arcpy.CopyFeatures_management(lst_polylines, fc)
if __name__ == '__main__':
    main()